summaryrefslogtreecommitdiff
path: root/scripts2/chewing.py
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2015-08-26 11:36:29 +0800
committerPeng Wu <alexepico@gmail.com>2015-08-26 11:36:29 +0800
commit5d2d133448e2ada2c2ebe8b10b6c4fef8b54fc8c (patch)
tree80e587f700b9f17441d12e6644029096ce23ce44 /scripts2/chewing.py
parent5fa4dea7beda95e27de1b6252ecf071c2d7112dd (diff)
downloadlibpinyin-5d2d133448e2ada2c2ebe8b10b6c4fef8b54fc8c.tar.gz
update chewing.py
Diffstat (limited to 'scripts2/chewing.py')
-rw-r--r--scripts2/chewing.py135
1 files changed, 72 insertions, 63 deletions
diff --git a/scripts2/chewing.py b/scripts2/chewing.py
index 5429ff4..00f0a9c 100644
--- a/scripts2/chewing.py
+++ b/scripts2/chewing.py
@@ -20,72 +20,81 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-ASCII_CHEWING_INITIAL_MAP = {
- "CHEWING_ZERO_INITIAL" : None, #Zero Initial
- "CHEWING_B" : "ㄅ",
- "CHEWING_C" : "ㄘ",
- "CHEWING_CH" : "ㄔ",
- "CHEWING_D" : "ㄉ",
- "CHEWING_F" : "ㄈ",
- "CHEWING_H" : "ㄏ",
- "CHEWING_G" : "ㄍ",
- "CHEWING_K" : "ㄎ",
- "CHEWING_J" : "ㄐ",
- "CHEWING_M" : "ㄇ",
- "CHEWING_N" : "ㄋ",
- "CHEWING_L" : "ㄌ",
- "CHEWING_R" : "ㄖ",
- "CHEWING_P" : "ㄆ",
- "CHEWING_Q" : "ㄑ",
- "CHEWING_S" : "ㄙ",
- "CHEWING_SH" : "ㄕ",
- "CHEWING_T" : "ㄊ",
- "PINYIN_W" : None, #Invalid Chewing
- "CHEWING_X" : "ㄒ",
- "PINYIN_Y" : None, #Invalid Chewing
- "CHEWING_Z" : "ㄗ",
- "CHEWING_ZH" : "ㄓ",
-}
+ASCII_CHEWING_INITIAL_LIST = [
+ ("CHEWING_ZERO_INITIAL" , None), #Zero Initial
+ ("CHEWING_B" , "ㄅ"),
+ ("CHEWING_C" , "ㄘ"),
+ ("CHEWING_CH" , "ㄔ"),
+ ("CHEWING_D" , "ㄉ"),
+ ("CHEWING_F" , "ㄈ"),
+ ("CHEWING_H" , "ㄏ"),
+ ("CHEWING_G" , "ㄍ"),
+ ("CHEWING_K" , "ㄎ"),
+ ("CHEWING_J" , "ㄐ"),
+ ("CHEWING_M" , "ㄇ"),
+ ("CHEWING_N" , "ㄋ"),
+ ("CHEWING_L" , "ㄌ"),
+ ("CHEWING_R" , "ㄖ"),
+ ("CHEWING_P" , "ㄆ"),
+ ("CHEWING_Q" , "ㄑ"),
+ ("CHEWING_S" , "ㄙ"),
+ ("CHEWING_SH" , "ㄕ"),
+ ("CHEWING_T" , "ㄊ"),
+ ("PINYIN_W" , None), #Invalid Chewing
+ ("CHEWING_X" , "ㄒ"),
+ ("PINYIN_Y" , None), #Invalid Chewing
+ ("CHEWING_Z" , "ㄗ"),
+ ("CHEWING_ZH" , "ㄓ"),
+]
-CHEWING_ASCII_INITIAL_MAP = dict([(v, k) for k, v in ASCII_CHEWING_INITIAL_MAP.items() if v])
+ASCII_CHEWING_INITIAL_MAP = dict(ASCII_CHEWING_INITIAL_LIST)
-ASCII_CHEWING_MIDDLE_MAP = {
- "CHEWING_ZERO_MIDDLE" : None, #Zero Middle
- "CHEWING_I" : "ㄧ",
- "CHEWING_U" : "ㄨ",
- "CHEWING_V" : "ㄩ",
-}
+CHEWING_ASCII_INITIAL_MAP = dict([(v, k) for k, v in ASCII_CHEWING_INITIAL_LIST if v])
-CHEWING_ASCII_MIDDLE_MAP = dict([(v, k) for k, v in ASCII_CHEWING_MIDDLE_MAP.items() if v])
-ASCII_CHEWING_FINAL_MAP = {
- "CHEWING_ZERO_FINAL" : None, #Zero Final
- "CHEWING_A" : "ㄚ",
- "CHEWING_AI" : "ㄞ",
- "CHEWING_AN" : "ㄢ",
- "CHEWING_ANG" : "ㄤ",
- "CHEWING_AO" : "ㄠ",
- "CHEWING_E" : "ㄝ", # merge "ㄝ" and "ㄜ"
- "INVALID_EA" : None, #Invalid Pinyin/Chewing
- "CHEWING_EI" : "ㄟ",
- "CHEWING_EN" : "ㄣ",
- "CHEWING_ENG" : "ㄥ",
- "CHEWING_ER" : "ㄦ",
- "CHEWING_NG" : "ㄫ",
- "CHEWING_O" : "ㄛ",
- "PINYIN_ONG" : None, #"ueng"
- "CHEWING_OU" : "ㄡ",
- "PINYIN_IN" : None, #"ien"
- "PINYIN_ING" : None, #"ieng"
-}
+ASCII_CHEWING_MIDDLE_LIST = [
+ ("CHEWING_ZERO_MIDDLE" , None), #Zero Middle
+ ("CHEWING_I" , "ㄧ"),
+ ("CHEWING_U" , "ㄨ"),
+ ("CHEWING_V" , "ㄩ"),
+]
-CHEWING_ASCII_FINAL_MAP = dict([(v, k) for k, v in ASCII_CHEWING_FINAL_MAP.items() if v])
+ASCII_CHEWING_MIDDLE_MAP = dict(ASCII_CHEWING_MIDDLE_LIST)
-ASCII_CHEWING_TONE_MAP = {
- "CHEWING_ZERO_TONE" : None, #Zero Tone
- "CHEWING_1" : " ",
- "CHEWING_2" : "ˊ",
- "CHEWING_3" : "ˇ",
- "CHEWING_4" : "ˋ",
- "CHEWING_5" : "˙",
-}
+CHEWING_ASCII_MIDDLE_MAP = dict([(v, k) for k, v in ASCII_CHEWING_MIDDLE_LIST if v])
+
+
+ASCII_CHEWING_FINAL_LIST = [
+ ("CHEWING_ZERO_FINAL" , None), #Zero Final
+ ("CHEWING_A" , "ㄚ"),
+ ("CHEWING_AI" , "ㄞ"),
+ ("CHEWING_AN" , "ㄢ"),
+ ("CHEWING_ANG" , "ㄤ"),
+ ("CHEWING_AO" , "ㄠ"),
+ ("CHEWING_E" , "ㄝ"), # merge "ㄝ" and "ㄜ"
+ ("INVALID_EA" , None), #Invalid Pinyin/Chewing
+ ("CHEWING_EI" , "ㄟ"),
+ ("CHEWING_EN" , "ㄣ"),
+ ("CHEWING_ENG" , "ㄥ"),
+ ("CHEWING_ER" , "ㄦ"),
+ ("CHEWING_NG" , "ㄫ"),
+ ("CHEWING_O" , "ㄛ"),
+ ("PINYIN_ONG" , None), #"ueng"
+ ("CHEWING_OU" , "ㄡ"),
+ ("PINYIN_IN" , None), #"ien"
+ ("PINYIN_ING" , None), #"ieng"
+]
+
+ASCII_CHEWING_FINAL_MAP = dict(ASCII_CHEWING_FINAL_LIST)
+
+CHEWING_ASCII_FINAL_MAP = dict([(v, k) for k, v in ASCII_CHEWING_FINAL_LIST if v])
+
+
+ASCII_CHEWING_TONE_LIST = [
+ ("CHEWING_ZERO_TONE" , None), #Zero Tone
+ ("CHEWING_1" , " "),
+ ("CHEWING_2" , "ˊ"),
+ ("CHEWING_3" , "ˇ"),
+ ("CHEWING_4" , "ˋ"),
+ ("CHEWING_5" , "˙"),
+]