summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-10-21 14:47:41 +0800
committerPeng Wu <alexepico@gmail.com>2011-10-21 14:47:41 +0800
commit7114c007f02e6005fd08b5647e48d53184a0739a (patch)
tree07097a35eb9e7700f434a32d69fd84ee3dc7281c /scripts
parent683ca48eb08e2ab80c476088be9be9756a80a796 (diff)
downloadlibpinyin-7114c007f02e6005fd08b5647e48d53184a0739a.tar.gz
libpinyin-7114c007f02e6005fd08b5647e48d53184a0739a.tar.xz
libpinyin-7114c007f02e6005fd08b5647e48d53184a0739a.zip
fixes get chewing
Diffstat (limited to 'scripts')
-rw-r--r--scripts/chewing.py2
-rw-r--r--scripts/correct.py (renamed from scripts/fuzzy.py)7
-rw-r--r--scripts/genpytable.py25
3 files changed, 25 insertions, 9 deletions
diff --git a/scripts/chewing.py b/scripts/chewing.py
index 856cf4a..22d18de 100644
--- a/scripts/chewing.py
+++ b/scripts/chewing.py
@@ -60,7 +60,7 @@ ASCII_CHEWING_FINAL_MAP = {
"CHEWING_AN" : "ㄢ",
"CHEWING_ANG" : "ㄤ",
"CHEWING_AO" : "ㄠ",
- "CHEWING_E" : "ㄜ",
+ "CHEWING_E" : "ㄝ", # merge "ㄝ" and "ㄜ"
"CHEWING_EI" : "ㄟ",
"CHEWING_EN" : "ㄣ",
"CHEWING_ENG" : "ㄥ",
diff --git a/scripts/fuzzy.py b/scripts/correct.py
index 8a94aa7..96b965c 100644
--- a/scripts/fuzzy.py
+++ b/scripts/correct.py
@@ -65,6 +65,8 @@ auto_correct_ext = [
("yun", "yven", "PINYIN_CORRECT_UEN_TO_UN | PINYIN_CORRECT_V_TO_U"),
]
+
+'''
fuzzy_shengmu = [
("c", "ch"),
("ch", "c"),
@@ -89,8 +91,5 @@ fuzzy_yunmu = [
("eng", "en"),
("in", "ing"),
("ing", "in"),
- ("ian", "iang"),
- ("iang", "ian"),
- ("uan", "uang"),
- ("uang", "uan"),
]
+'''
diff --git a/scripts/genpytable.py b/scripts/genpytable.py
index b285d76..ed2686f 100644
--- a/scripts/genpytable.py
+++ b/scripts/genpytable.py
@@ -23,7 +23,7 @@
import pinyin
import bopomofo
import chewing
-from fuzzy import *
+from correct import *
def check_pinyin_chewing_map():
@@ -34,12 +34,24 @@ def check_pinyin_chewing_map():
print("pinyin %s has no chewing mapping", pinyin_key)
def get_chewing(pinyin_key):
- initial = 'CHEWING_ZERO_INITIAL'
- middle = 'CHEWING_ZERO_MIDDLE'
- final = 'CHEWING_ZERO_FINAL'
+ initial, middle, final = \
+ 'CHEWING_ZERO_INITIAL', 'CHEWING_ZERO_MIDDLE', 'CHEWING_ZERO_FINAL'
assert pinyin_key != None
assert pinyin_key in bopomofo.PINYIN_BOPOMOFO_MAP
+
+ #handle 'w' and 'y'
+ if pinyin_key[0] == 'w':
+ initial = 'PINYIN_W'
+ if pinyin_key[0] == 'y':
+ initial = 'PINYIN_Y'
+
+ #get chewing string
bopomofo_str = bopomofo.PINYIN_BOPOMOFO_MAP[pinyin_key]
+
+ #handle 'ci', 'chi', 'si', 'shi', 'zi', 'zhi', 'ri'
+ if pinyin_key in {'ci', 'chi', 'si', 'shi', 'zi', 'zhi', 'ri'}:
+ middle = "CHEWING_I"
+ #normal process
for char in bopomofo_str:
if char in chewing.CHEWING_ASCII_INITIAL_MAP:
initial = chewing.CHEWING_ASCII_INITIAL_MAP[char]
@@ -47,6 +59,11 @@ def get_chewing(pinyin_key):
middle = chewing.CHEWING_ASCII_MIDDLE_MAP[char]
if char in chewing.CHEWING_ASCII_FINAL_MAP:
final = chewing.CHEWING_ASCII_FINAL_MAP[char]
+ if char == "ㄜ":
+ final = "CHEWING_E"
+
+ if middle == "CHEWING_U" and final == "CHEWING_ENG":
+ middle, final = "CHEWING_ZERO_MIDDLE", "PINYIN_ONG"
return initial, middle, final