# Rime schema
# encoding: utf-8

schema:
  schema_id: hkcantonese
  name: 香港廣東話拼音
  version: "0.2"
  author:
    - Matthew Wo <9029537@gmail.com>
  description: |
    香港廣東話拼音方案
    https://zh.wikipedia.org/wiki/%E9%A6%99%E6%B8%AF%E6%94%BF%E5%BA%9C%E7%B2%B5%E8%AA%9E%E6%8B%BC%E9%9F%B3
  dependencies:
    - luna_pinyin

switches:
  - name: ascii_mode
    reset: 0
    states: [ 中文, 西文 ]
  - name: full_shape
    states: [ 半角, 全角 ]
  - name: simplification
    states: [ 漢字, 汉字 ]
  - name: ascii_punct
    states: [ 。，, ．， ]

engine:
  processors:
    - ascii_composer
    - recognizer
    - key_binder
    - speller
    - punctuator
    - selector
    - navigator
    - express_editor
  segmentors:
    - ascii_segmentor
    - matcher
    - abc_segmentor
    - punct_segmentor
    - fallback_segmentor
  translators:
    - punct_translator
    - script_translator
    - reverse_lookup_translator
  filters:
    - simplifier
    - uniquifier

speller:
  alphabet: zyxwvutsrqponmlkjihgfedcba
  delimiter: " '"
  algebra:
    - derive/aa/a/               # 煆 haa -> ha
    - derive/eo/eu/              # 蹲 deon -> deun
    - derive/oe/eu/              # 剁 doek -> deuk
    - derive/eot/ut/             # 出 ceot -> chut
    - derive/eon/un/             # 論 leon -> lun
    - derive/eon/hun/            # 純 seon -> shun
    - derive/yun/uen/            # 算 syun -> suen
    - derive/u/ue/               # 冤 yun -> yuen
    - derive/^jy/y/              # 粵 jyut -> yut
    - derive/^j/y/               # 用 jung -> yung
    - derive/^z/j/               # 抓 zaa -> ja
    - derive/^c/ch/              # 叉 caa -> cha
    - derive/^gw/g/              # 廣 gwong -> gong
    - derive/eu$/iu/             # 掉 deu -> diu
    - derive/em$/im/             # 舐 lem -> lim
    - derive/ep$/ip/             # 夾 gep -> gip
    - derive/eoi$/ui/            # 最 zeoi -> jui
    - derive/yu$/hu/             # 舒 syu -> shu
    - derive/un$/oon/            # 盤 pun -> poon
    - derive/eong$/eung/         # 將 zeong -> zeung
    - derive/(.)a$/$1h/          # 呀 aa -> ah
    - derive/^[nl](.)$/l$1/      # 呢 ne -> le
    - derive/^ng([a-z]*)/$1/     # 牙 ngaa -> aa
    - derive/^([a-z]*)yu$/$1u/   # 豬 zyu -> ju
    - derive/^([a-z]*)ou$/$1o/   # 好 hou -> ho
    - derive/^(.)o$/$1oh/        # 科 fo -> foh
    - derive/^[nl]([a-z]*)/l$1/  # 難 naan -> laan
    - abbrev/^([a-z]).+$/$1/     # 首字母簡拼
    - abbrev/^(ng).+$/$1/        # 聲母簡拼
    - abbrev/^(ch).+$/$1/        # 聲母簡拼
    - abbrev/^([gk]w).+$/$1/     # 聲母簡拼

translator:
  dictionary: jyutping
  prism: yale
  spelling_hints: 10
  comment_format: &comment_rules

reverse_lookup:
  dictionary: luna_pinyin
  prefix: "`"
  suffix: "'"
  tips: 〔拼音〕
  preedit_format:
    - xform/([nl])v/$1ü/
    - xform/([nl])ue/$1üe/
    - xform/([jqxy])v/$1u/
  comment_format: *comment_rules

punctuator:
  import_preset: default

key_binder:
  import_preset: default

recognizer:
  import_preset: default
  patterns:
    reverse_lookup: "`[a-z]*'?$"
