diff options
author | Peng Huang <shawn.p.huang@gmail.com> | 2010-05-12 17:34:38 +0800 |
---|---|---|
committer | Peng Huang <shawn.p.huang@gmail.com> | 2010-05-12 20:18:27 +0800 |
commit | e37e15be51cab2dfe85785b17a4707c09de402cd (patch) | |
tree | cf14a24a0f44facfe08060bd7d0b8978d5fa2e28 /scripts | |
parent | 0fe0c8fdb5c2ce9090394034a505427b1aeab176 (diff) | |
download | ibus-pinyin-e37e15be51cab2dfe85785b17a4707c09de402cd.tar.gz |
Generate some fuzzy bopomofo
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/bopomofo.py | 68 | ||||
-rw-r--r-- | scripts/genpytable.py | 23 |
2 files changed, 91 insertions, 0 deletions
diff --git a/scripts/bopomofo.py b/scripts/bopomofo.py index c4c0a65..05f1327 100644 --- a/scripts/bopomofo.py +++ b/scripts/bopomofo.py @@ -447,3 +447,71 @@ bopomofo_pinyin_map = { } pinyin_bopomofo_map = dict([(v, k) for k, v in bopomofo_pinyin_map.items()]) + +sheng_yun_bopomofo_map = { + "b" : "ㄅ", + "p" : "ㄆ", + "m" : "ㄇ", + "f" : "ㄈ", + "d" : "ㄉ", + "t" : "ㄊ", + "n" : "ㄋ", + "l" : "ㄌ", + "g" : "ㄍ", + "k" : "ㄎ", + "h" : "ㄏ", + "j" : "ㄐ", + "q" : "ㄑ", + "x" : "ㄒ", + "zh" : "ㄓ", + "ch" : "ㄔ", + "sh" : "ㄕ", + "r" : "ㄖ", + "z" : "ㄗ", + "c" : "ㄘ", + "s" : "ㄙ", + + # 韻母為u,ue,un,uan,ong時ㄧ省略 + "y" : ("ㄧ", (("u", "ue", "un", "uan", "ong"), "")), + "w" : "ㄨ", + "a" : "ㄚ", + "o" : "ㄛ", + "e" : ("ㄜ", ("y", "ㄝ")), # y後面為ㄝ + + # zh ch sh r z c s y後面為空 + "i" : ("ㄧ", (("zh", "ch", "sh", "r", "z", "c", "s", "y"), "")), + + # jqxy後面為ㄩ w後面為空 + "u" : ("ㄨ", ("jqxy", "ㄩ")), + "v" : "ㄩ", + "ai" : "ㄞ", + "ei" : "ㄟ", + "ao" : "ㄠ", + "ou" : "ㄡ", + "an" : "ㄢ", + "en" : "ㄣ", + "ang" : "ㄤ", + "eng" : "ㄥ", + "er" : "ㄦ", + "ia" : "ㄧㄚ", + "ie" : "ㄧㄝ", + "iai" : "ㄧㄞ", + "iao" : "ㄧㄠ", + "iu" : "ㄧㄡ", + "ian" : "ㄧㄢ", + "in" : ("ㄧㄣ", ("y", "ㄣ")), #y後面為ㄣ + "iang" : "ㄧㄤ", + "ing" : ("ㄧㄥ", ("y", "ㄥ")), #y後面為ㄥ + "ua" : "ㄨㄚ", + "uo" : "ㄨㄛ", + "ue" : "ㄩㄝ", + # TODO: "ve" is OK? + "ve" : "ㄩㄝ", + "uai" : "ㄨㄞ", + "ui" : "ㄨㄟ", + "uan" : ("ㄨㄢ", ("jqxy", "ㄩㄢ")), # jqxy後面是ㄩㄢ + "un" : ("ㄨㄣ", ("jqxy", "ㄩㄣ")), # jqxy後面是ㄩㄣ + "uang" : ("ㄨㄤ", ("jqxy", "ㄩㄤ")), # jqxy後面是ㄩㄤ + "ong" : ("ㄨㄥ", ("jqxy", "ㄩㄥ")), # y後面為ㄩㄥ + "iong" : "ㄩㄥ", +} diff --git a/scripts/genpytable.py b/scripts/genpytable.py index 5021718..633e358 100644 --- a/scripts/genpytable.py +++ b/scripts/genpytable.py @@ -222,6 +222,28 @@ def get_pinyin_with_fuzzy(): bopomofo = pinyin_bopomofo_map.get(text, "") + if bopomofo == "": + if all([f.startswith("PINYIN_FUZZY_") for f in flags[0].split(" | ")]): + #if it is fuzzy pinyin or normal pinyin + if s in sheng_yun_bopomofo_map and y in sheng_yun_bopomofo_map: + if isinstance(sheng_yun_bopomofo_map[s], str): + bopomofo = sheng_yun_bopomofo_map[s] + else: + if y in sheng_yun_bopomofo_map[s][1][0]: + bopomofo += sheng_yun_bopomofo_map[s][1][1] + else: + bopomofo += sheng_yun_bopomofo_map[s][0] + + if isinstance(sheng_yun_bopomofo_map[y], str): + bopomofo += sheng_yun_bopomofo_map[y] + else: + if s in sheng_yun_bopomofo_map[y][1][0]: + bopomofo += sheng_yun_bopomofo_map[y][1][1] + else: + bopomofo += sheng_yun_bopomofo_map[y][0] + else: + print text + yield text, bopomofo, s, y, fs1, fy1, fs2, fy2, l, flags @@ -315,6 +337,7 @@ def gen_bopomofo_table(pinyins): if p[1]: print ' %-20s %s' % ('&pinyin_table[%d],' % i, '// "%s" => "%s"' % (p[1], p[0])) print '};' + print def get_all_special(pinyins): for p in pinyins: |