From 9532617ce6542916b8eb5e30153f09aeeb5a54fa Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Tue, 8 Nov 2011 16:35:56 +0800 Subject: add comments --- scripts/genpinyintable.py | 2 +- scripts/genspecialtable.py | 6 +++--- scripts/pinyintable.py | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/genpinyintable.py b/scripts/genpinyintable.py index e90b104..9a1a273 100644 --- a/scripts/genpinyintable.py +++ b/scripts/genpinyintable.py @@ -47,7 +47,7 @@ def sort_all(): sortfunc = operator.itemgetter(0) #begin sort content_table = sorted(content_table, key=sortfunc) - #prepend zero item + #prepend zero item to reserve the invalid item content_table.insert(0, ("", "", "ChewingKey()")) #sort index pinyin_index = sorted(pinyin_index, key=sortfunc) diff --git a/scripts/genspecialtable.py b/scripts/genspecialtable.py index c7384b5..9abe0e4 100644 --- a/scripts/genspecialtable.py +++ b/scripts/genspecialtable.py @@ -41,12 +41,12 @@ def get_chewing_string(pinyin): #handle shengmu if pinyin not in pinyin_list: if pinyin in shengmu_list: - (initial, middle, final) = get_shengmu_chewing(pinyin) + chewing_key = get_shengmu_chewing(pinyin) else: assert False, "Un-expected pinyin string." else: - (initial, middle, final) = get_chewing(pinyin) - chewing_str = 'ChewingKey({0}, {1}, {2})'.format(initial, middle, final) + chewing_key = get_chewing(pinyin) + chewing_str = 'ChewingKey({0})'.format(', '.join(chewing_key)) return chewing_str diff --git a/scripts/pinyintable.py b/scripts/pinyintable.py index 94fef20..603159e 100644 --- a/scripts/pinyintable.py +++ b/scripts/pinyintable.py @@ -139,6 +139,7 @@ def gen_corrects(): flags = ['IS_PINYIN', 'PINYIN_CORRECT_{0}_{1}'.format(wrong.upper(), correct.upper())] for pinyin_key in pinyin_list: + #fixes partial pinyin instead of the whole pinyin if pinyin_key.endswith(correct) and pinyin_key != correct: chewing_key = bopomofo.PINYIN_BOPOMOFO_MAP[pinyin_key] new_pinyin_key = pinyin_key.replace(correct, wrong) -- cgit