From a9ecf6dd0d492243dc4a38792411e5fa7c79f40b Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Thu, 29 Mar 2012 14:16:23 +0800 Subject: [PATCH] update special table --- scripts/genspecialtable.py | 13 +++++-------- src/storage/pinyin_parser2.h | 8 ++++---- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/scripts/genspecialtable.py b/scripts/genspecialtable.py index df0c30f..a835bff 100644 --- a/scripts/genspecialtable.py +++ b/scripts/genspecialtable.py @@ -37,6 +37,7 @@ def sort_all(): divided_list = sorted(divided_list, key=operator.itemgetter(0)) resplit_list = sorted(resplit_list, key=operator.itemgetter(0, 1)) +''' def get_chewing_string(pinyin): #handle shengmu if pinyin not in pinyin_list: @@ -48,19 +49,17 @@ def get_chewing_string(pinyin): chewing_key = get_chewing(pinyin) chewing_str = 'ChewingKey({0})'.format(', '.join(chewing_key)) return chewing_str - +''' def gen_divided_table(): entries = [] for (pinyin_key, orig_freq, first_key, second_key, new_freq) \ in divided_list: - (pinyin_key, first_key, second_key) = map \ - (get_chewing_string, (pinyin_key, first_key, second_key)) if orig_freq >= new_freq: assert orig_freq > 0, "Expected orig_freq > 0 here." - entry = '{{{0}, {1}, {{{2}, {3}}}, {4}}}'.format \ + entry = '{{"{0}", {1}, {{"{2}", "{3}"}}, {4}}}'.format \ (pinyin_key, orig_freq, first_key, second_key, new_freq) entries.append(entry) return ',\n'.join(entries) @@ -70,13 +69,11 @@ def gen_resplit_table(): entries = [] for (orig_first_key, orig_second_key, orig_freq, \ new_first_key, new_second_key, new_freq) in resplit_list: - (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)) + if orig_freq >= new_freq: assert orig_freq > 0, "Expected orig_freq > 0 here." - entry = '{{{{{0}, {1}}}, {2}, {{{3}, {4}}}, {5}}}'.format \ + entry = '{{{{"{0}", "{1}"}}, {2}, {{"{3}", "{4}"}}, {5}}}'.format \ (orig_first_key, orig_second_key, orig_freq,\ new_first_key, new_second_key, new_freq) entries.append(entry) diff --git a/src/storage/pinyin_parser2.h b/src/storage/pinyin_parser2.h index 5f81b00..2f5fc76 100644 --- a/src/storage/pinyin_parser2.h +++ b/src/storage/pinyin_parser2.h @@ -48,16 +48,16 @@ typedef struct { } chewing_index_item_t; typedef struct { - ChewingKey m_orig_key; + const char * m_orig_key; guint32 m_orig_freq; - ChewingKey m_new_keys[2]; + const char * m_new_keys[2]; guint32 m_new_freq; } divided_table_item_t; typedef struct { - ChewingKey m_orig_keys[2]; + const char * m_orig_keys[2]; guint32 m_orig_freq; - ChewingKey m_new_keys[2]; + const char * m_new_keys[2]; guint32 m_new_freq; } resplit_table_item_t; -- 2.7.4