summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2012-01-05 11:17:49 +0800
committerPeng Wu <alexepico@gmail.com>2012-01-05 11:20:20 +0800
commit69a66088a60c6ae03462f8fba49383e5b4772b46 (patch)
tree2d13c08f75066ea7958c1b307d7a9185a09cd791
parent8af616069b4805d43dc554a33d7d4503f9a87782 (diff)
downloadlibpinyin-69a66088a60c6ae03462f8fba49383e5b4772b46.tar.gz
libpinyin-69a66088a60c6ae03462f8fba49383e5b4772b46.tar.xz
libpinyin-69a66088a60c6ae03462f8fba49383e5b4772b46.zip
fixes chewing index
-rw-r--r--scripts/bopomofo.py4
-rw-r--r--scripts/genpinyintable.py8
-rw-r--r--scripts/pinyintable.py7
3 files changed, 13 insertions, 6 deletions
diff --git a/scripts/bopomofo.py b/scripts/bopomofo.py
index 09a7b88..fe11b1a 100644
--- a/scripts/bopomofo.py
+++ b/scripts/bopomofo.py
@@ -457,6 +457,9 @@ BOPOMOFO_PINYIN_MAP = {
PINYIN_BOPOMOFO_MAP = dict([(v, k) for k, v in BOPOMOFO_PINYIN_MAP.items()])
+SPECIAL_INITIAL_SET = {'ci', 'chi', 'si', 'shi', 'zi', 'zhi', 'ri'}
+
+'''
SHENG_YUN_BOPOMOFO_MAP = {
"b" : "ㄅ",
"p" : "ㄆ",
@@ -524,3 +527,4 @@ SHENG_YUN_BOPOMOFO_MAP = {
"ong" : ("ㄨㄥ", ("jqxy", "ㄩㄥ")), # y後面為ㄩㄥ
"iong" : "ㄩㄥ",
}
+'''
diff --git a/scripts/genpinyintable.py b/scripts/genpinyintable.py
index c0f91c6..05c0419 100644
--- a/scripts/genpinyintable.py
+++ b/scripts/genpinyintable.py
@@ -20,6 +20,7 @@
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
import operator
+import bopomofo
from pinyintable import *
from chewingkey import gen_table_index
@@ -38,7 +39,7 @@ def filter_pinyin_list():
if "IS_PINYIN" in flags:
pinyin_index.append((wrong, flags, correct))
if "IS_CHEWING" in flags:
- bopomofo_index.append((bopomofo, flags, bopomofo))
+ bopomofo_index.append((bopomofo, flags))
def sort_all():
@@ -77,8 +78,9 @@ def gen_pinyin_index():
def gen_bopomofo_index():
entries = []
- for (bopomofo_str, flags, bopomofo) in bopomofo_index:
- index = [x[1] for x in content_table].index(bopomofo)
+ for (bopomofo_str, flags) in bopomofo_index:
+ pinyin_str = bopomofo.BOPOMOFO_PINYIN_MAP[bopomofo_str]
+ index = [x[0] for x in content_table].index(pinyin_str)
entry = '{{"{0}", {1}, {2}}}'.format(bopomofo_str, flags, index)
entries.append(entry)
return ',\n'.join(entries)
diff --git a/scripts/pinyintable.py b/scripts/pinyintable.py
index a1d8d3e..33b5e9c 100644
--- a/scripts/pinyintable.py
+++ b/scripts/pinyintable.py
@@ -53,8 +53,8 @@ def get_chewing(pinyin_key):
#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'}:
+ #handle bopomofo SPECIAL_INITIAL_SET
+ if pinyin_key in bopomofo.SPECIAL_INITIAL_SET:
middle = "CHEWING_I"
#normal process
for char in bopomofo_str:
@@ -105,7 +105,8 @@ def gen_pinyins():
if pinyin_key in shengmu_list:
flags.append("PINYIN_INCOMPLETE")
chewing_key = bopomofo.PINYIN_BOPOMOFO_MAP[pinyin_key]
- if chewing_key in chewing.CHEWING_ASCII_INITIAL_MAP:
+ if chewing_key in chewing.CHEWING_ASCII_INITIAL_MAP and \
+ pinyin_key not in bopomofo.SPECIAL_INITIAL_SET:
flags.append("CHEWING_INCOMPLETE")
yield pinyin_key, pinyin_key, chewing_key, \
flags, get_chewing(pinyin_key)