# Rime schema
# encoding: utf-8

schema:
  schema_id: combo_pinyin
  name: 宮保拼音
  version: "0.6"
  author:
    - 佛振 <chen.sst@gmail.com>
  description: |
    並擊輸入拼音

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

engine:
  processors:
    - ascii_composer
    - chord_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
  filters:
    - simplifier
    - uniquifier

speller:
  alphabet: zyxwvutsrqponmlkjihgfedcba
  delimiter: " '"
  algebra:
    - erase/^xx$/

chord_composer:
  # 字母表，包含用於並擊的按鍵
  # 擊鍵雖有先後，形成並擊時，一律以字母表順序排列
  alphabet: "swxdecfrvgtbnjum ki,lo."
  # 拼寫運算規則，將一組並擊編碼轉換爲拼音音節
  algebra:
    # 先將物理按鍵字符對應到宮保拼音鍵位中的拼音字母
    - 'xlit|swxdecfrvgtbnjum ki,lo.|sczhlfgdbktpRiuVaNIUeoE|'
    # 以下根據宮保拼音的鍵位分別變換聲母、韻母部分
    # 組合聲母
    - xform/^zf/zh/
    - xform/^cl/ch/
    - xform/^fb/m/
    - xform/^ld/n/
    - xform/^hg/r/
    # g,k,h 接 i/ü 時作 ji/ju, qi/qu, xi/xu
    - xform/^[gz]([iV])/j$1/
    - xform/^[kc]([iV])/q$1/
    - xform/^[hs]([iV])/x$1/
    # 空格鍵單擊時產生空白
    - 'xform/^a$/ /'
    # 特例：以組合鍵[ae]輸入拼音‹a›
    - xform/ae$/a/
    # 單擊時產生字符 , .
    - xform/^U$/,/
    - xform/^E$/./
    # 上排三鍵並擊 ong, uang
    - xform/(ua?)Io$/$1Ne/
    - xform/aI$/ai/
    - xform/I[oe]$/ei/
    - xform/uI$/uei/
    # I 鍵亦可用作韻母 ‹i›
    - xform/^gI$/ji/
    - xform/^kI$/qi/
    - xform/^hI$/xi/
    - xform/I$/i/
    # 下排三鍵並擊 iong
    - xform/VUE$/VNe/
    # [ü] 活用爲介音 ‹i-› 以利於並擊 iao, iu
    - xform/V(a?)U$/i$1U/
    - xform/aU$/ao/
    - xform/UE?$/ou/
    - xform/([aiuV])Ne$/$1ng/
    # ‹eng› 省略 ‹e›
    - xform/Ne$/eng/
    - xform/^ung$/weng/
    - xform/ung$/ong/
    - xform/Vng$/iong/
    - xform/([aiuV])N$/$1n/
    # ‹en› 省略 ‹e›
    - xform/N$/en/
    - xform/^un$/wen/
    - xform/R$/er/
    # 漢語拼音方案的拼寫規則
    - xform/^i(ng?)$/yi$1/
    - xform/^i$/yi/
    - xform/^i/y/
    - xform/^u$/wu/
    - xform/^u/w/
    - xform/^V/yu/
    - xform/^([jqx])V/$1u/
    # 一些容錯
    - xform/^([zcsr]h?)i([aoe])/$1$2/
    - xform/^([zcsr]h?)i(ng?)$/$1e$2/
    # 拼寫規則
    - xform/iou$/iu/
    - xform/uei$/ui/
    - xlit/VE/ve/
    # 聲母獨用時補足隠含的韻母
    - xform/^([bpf])$/$1u/
    - xform/^([mdtnlgkh])$/$1e/
    - xform/^([mdtnlgkh])$/$1e/
    - xform/^([zcsr]h?)$/$1i/
  # 並擊完成後套用的式樣
  output_format:
    # 追加隔音符號
    - "xform/^([bpm])([iu]|a|i?e|o|[ae]i|i?ao|[oi]u|i?an|[ie]n|[ei]ng|ang|ong)$/$1$2'/"
    - "xform/^([fw])(u|a|o|[ae]i|ao|ou|an|en|eng|ang|ong)$/$1$2'/"
    - "xform/^([dtnl])([iuv]|i?a|[iv]?e|u?o|[aeu]i|i?ao|[oi]u|[iu]?an|[iue]n|[ei]ng|i?ang|ong)$/$1$2'/"
    - "xform/^([gkh])(u|u?a|e|uo|u?ai|[ue]i|ao|ou|u?an|[ue]n|eng|u?ang|ong)$/$1$2'/"
    - "xform/^([zcs]h?|r)([iu]|u?a|e|uo|u?ai|[ue]i|ao|ou|u?an|[ue]n|eng|u?ang|ong)$/$1$2'/"
    - "xform/^([jqxy])([iu]|i?a|[iu]?e|o|i?ao|[oi]u|[iu]?an|[iu]n|ing|i?ang|i?ong)$/$1$2'/"
    - "xform/^([aeo]|[ae]i|ao|ou|[ae]ng?|er)$/$1'/"
    # 消除不構成合法音節的並擊組合
    - "erase/^([A-Za-z]+)$/"
  # 並擊過程中套用的式樣
  prompt_format:
    # 加方括弧
    - "xform/^(.*)$/[$1]/"

translator:
  dictionary: luna_pinyin
  prism: combo_pinyin
  preedit_format:
    - xform/([nl])v/$1ü/
    - xform/([nl])ue/$1üe/
    - xform/([jqxy])v/$1u/

punctuator:
  import_preset: default

key_binder:
  import_preset: default

recognizer:
  import_preset: default
