diff options
author | Peng Wu <alexepico@gmail.com> | 2011-11-05 11:47:55 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2011-11-05 12:15:44 +0800 |
commit | e7087ceb62f26c74460519ff7afd60fb9c7300b9 (patch) | |
tree | 021767e58a4edc15e25041f0e14bdfcb6687bfb4 /scripts | |
parent | e4fa71454b95d5f3b13e5e43fa6788d2bd3bfb02 (diff) | |
download | libpinyin-e7087ceb62f26c74460519ff7afd60fb9c7300b9.tar.gz libpinyin-e7087ceb62f26c74460519ff7afd60fb9c7300b9.tar.xz libpinyin-e7087ceb62f26c74460519ff7afd60fb9c7300b9.zip |
improves gen special table
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/genspecialtable.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/scripts/genspecialtable.py b/scripts/genspecialtable.py index a53be7a..c7384b5 100644 --- a/scripts/genspecialtable.py +++ b/scripts/genspecialtable.py @@ -68,9 +68,17 @@ def gen_resplit_table(): (orig_first_key, orig_second_key, new_first_key, new_second_key) = map\ (get_chewing_string, (orig_first_key, orig_second_key, \ new_first_key, new_second_key)) - entry = '{{{0}, {1}, {2}, {3}, {4}, {5}}}'.format \ - (orig_first_key, orig_second_key, orig_freq, \ - new_first_key, new_second_key, new_freq) + if new_freq > orig_freq: + if orig_freq == 0: + benefit = 0.5 + else: + benefit = 0.3 + elif orig_freq >= new_freq: + assert orig_freq > 0, "Expected orig_freq > 0 here." + benefit = 0 + entry = '{{{0}, {1}, {2}, {3}, {4}}}'.format \ + (orig_first_key, orig_second_key, \ + new_first_key, new_second_key, benefit) entries.append(entry) return ',\n'.join(entries) |