summaryrefslogtreecommitdiffstats
path: root/scripts2
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2016-05-16 14:40:05 +0800
committerPeng Wu <alexepico@gmail.com>2016-05-16 14:45:59 +0800
commit7b4c05dc1766a2b7698e044b5c393bd321e4e795 (patch)
treebf3d1d346e577bc090ff28c142ed260017f458b0 /scripts2
parent5bfc05a8e0223a95c10f688043dbecc444ae7cfa (diff)
downloadlibpinyin-7b4c05dc1766a2b7698e044b5c393bd321e4e795.tar.gz
libpinyin-7b4c05dc1766a2b7698e044b5c393bd321e4e795.tar.xz
libpinyin-7b4c05dc1766a2b7698e044b5c393bd321e4e795.zip
update scripts
Diffstat (limited to 'scripts2')
-rw-r--r--scripts2/specialtable.py24
1 files changed, 19 insertions, 5 deletions
diff --git a/scripts2/specialtable.py b/scripts2/specialtable.py
index 800a7b1..17bd673 100644
--- a/scripts2/specialtable.py
+++ b/scripts2/specialtable.py
@@ -25,6 +25,7 @@ import sys
import math
import operator
from fullpinyin import PINYIN_LIST, SHENGMU_LIST, YUNMU_LIST
+from fullpinyintable import content_table
pinyin_list = sorted(PINYIN_LIST)
shengmu_list = sorted(SHENGMU_LIST)
@@ -125,6 +126,13 @@ def sort_all():
resplit_list = sorted(resplit_list, key=operator.itemgetter(0, 1))
+def get_chewing_key(pinyin):
+ # item[4] is chewing key, item[0] is pinyin
+ for item in content_table:
+ if pinyin == item[0]:
+ return item[4]
+
+
def gen_divided_table():
entries = []
for (pinyin_key, orig_freq, first_key, second_key, new_freq) \
@@ -133,8 +141,10 @@ def gen_divided_table():
if orig_freq >= new_freq:
assert orig_freq > 0, "Expected orig_freq > 0 here."
- entry = '{{"{0}", {1}, {{"{2}", "{3}"}}, {4}}}'.format \
- (pinyin_key, orig_freq, first_key, second_key, new_freq)
+ entry = '{{"{0}", {1}, {2}, {{"{3}", "{4}"}}, {{{5}, {6}}}, {7}}}'.format \
+ (pinyin_key, get_chewing_key(pinyin_key), orig_freq, \
+ first_key, second_key, \
+ get_chewing_key(first_key), get_chewing_key(second_key), new_freq)
entries.append(entry)
return ',\n'.join(entries)
@@ -147,9 +157,13 @@ def gen_resplit_table():
if orig_freq >= new_freq:
assert orig_freq > 0, "Expected orig_freq > 0 here."
- entry = '{{{{"{0}", "{1}"}}, {2}, {{"{3}", "{4}"}}, {5}}}'.format \
- (orig_first_key, orig_second_key, orig_freq,\
- new_first_key, new_second_key, new_freq)
+ entry = '{{{{"{0}", "{1}"}}, {{{2}, {3}}}, {4}, {{"{5}", "{6}"}}, {{{7}, {8}}}, {9}}}'.format \
+ (orig_first_key, orig_second_key, \
+ get_chewing_key(orig_first_key), \
+ get_chewing_key(orig_second_key), orig_freq,\
+ new_first_key, new_second_key, \
+ get_chewing_key(new_first_key), \
+ get_chewing_key(new_second_key), new_freq)
entries.append(entry)
return ',\n'.join(entries)