summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-11-02 13:36:42 +0800
committerPeng Wu <alexepico@gmail.com>2011-11-02 13:36:42 +0800
commite8855f5885f12504e7d8d13014505a44dab44a94 (patch)
treed774435efaf70d602bf16c811f2ab415a1040b3e /scripts
parent75546099491c6082f5f8fe0a16f7dd1cbd5d4fdb (diff)
downloadlibpinyin-e8855f5885f12504e7d8d13014505a44dab44a94.tar.gz
libpinyin-e8855f5885f12504e7d8d13014505a44dab44a94.tar.xz
libpinyin-e8855f5885f12504e7d8d13014505a44dab44a94.zip
write gen pinyin table
Diffstat (limited to 'scripts')
-rw-r--r--scripts/gentable.py22
1 files changed, 20 insertions, 2 deletions
diff --git a/scripts/gentable.py b/scripts/gentable.py
index 0e98379..1a325be 100644
--- a/scripts/gentable.py
+++ b/scripts/gentable.py
@@ -62,9 +62,27 @@ def gen_context_table():
return ',\n'.join(entries)
+def gen_pinyin_index():
+ entries = []
+ for (wrong, flags, correct) in pinyin_index:
+ index = [x[0] for x in content_table].index(correct)
+ entry = '{{"{0}", {1}, {2}}}'.format(wrong, flags, index)
+ entries.append(entry)
+ return ',\n'.join(entries)
+
+
+def gen_bopomofo_index():
+ entries = []
+ for (bopomofo_str, flags, bopomofo) in bopomofo_index:
+ index = [x[0] for x in content_table].index(bopomofo)
+ entry = '{{"{0}", {1}, {2}}}'.format(bopomofo_str, flags, index)
+ entries.append(entry)
+ return ',\n'.join(entries)
+
+
### main function ###
if __name__ == "__main__":
filter_pinyin_list()
sort_all()
- table = gen_context_table()
- print(table)
+ s = gen_pinyin_index()
+ print(s)