From 28445f269c3fc125f72c4523624305e64584639b Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Mon, 4 Jul 2016 11:12:04 +0800 Subject: clean pinyin_parser2.cpp --- src/storage/pinyin_parser2.cpp | 184 ----------------------------------------- 1 file changed, 184 deletions(-) (limited to 'src/storage') diff --git a/src/storage/pinyin_parser2.cpp b/src/storage/pinyin_parser2.cpp index fb35585..df54820 100644 --- a/src/storage/pinyin_parser2.cpp +++ b/src/storage/pinyin_parser2.cpp @@ -388,190 +388,6 @@ bool FullPinyinParser2::set_scheme(FullPinyinScheme scheme){ return true; } -#if 0 -bool FullPinyinParser2::post_process2(pinyin_option_t options, - ChewingKeyVector & keys, - ChewingKeyRestVector & key_rests, - const char * str, - int len) const { - int i; - assert(keys->len == key_rests->len); - gint num_keys = keys->len; - - ChewingKey * cur_key = NULL, * next_key = NULL; - ChewingKeyRest * cur_rest = NULL, * next_rest = NULL; - guint16 next_tone = CHEWING_ZERO_TONE; - - for (i = 0; i < num_keys - 1; ++i) { - cur_rest = &g_array_index(key_rests, ChewingKeyRest, i); - next_rest = &g_array_index(key_rests, ChewingKeyRest, i + 1); - - /* some "'" here */ - if (cur_rest->m_raw_end != next_rest->m_raw_begin) - continue; - - cur_key = &g_array_index(keys, ChewingKey, i); - next_key = &g_array_index(keys, ChewingKey, i + 1); - - /* some tone here */ - if (CHEWING_ZERO_TONE != cur_key->m_tone) - continue; - - /* back up tone */ - if (options & USE_TONE) { - next_tone = next_key->m_tone; - if (CHEWING_ZERO_TONE != next_tone) { - next_key->m_tone = CHEWING_ZERO_TONE; - next_rest->m_raw_end --; - } - } - - /* lookup re-split table */ - const resplit_table_item_t * item = NULL; - - item = retrieve_resplit_item_by_original_pinyins - (options, cur_key, cur_rest, next_key, next_rest, str, len); - - if (item) { - /* no ops */ - if (item->m_orig_freq >= item->m_new_freq) - continue; - - /* do re-split */ - size_t len = strlen(item->m_new_keys[0]); - *cur_key = item->m_new_structs[0]; - cur_rest->m_raw_end = cur_rest->m_raw_begin + len; - - next_rest->m_raw_begin = cur_rest->m_raw_end; - len = strlen(item->m_new_keys[1]); - *next_key = item->m_new_structs[1]; - } - - /* restore tones */ - if (options & USE_TONE) { - if (CHEWING_ZERO_TONE != next_tone) { - next_key->m_tone = next_tone; - next_rest->m_raw_end ++; - } - } - } - - return true; -} - -const divided_table_item_t * FullPinyinParser2::retrieve_divided_item -(pinyin_option_t options, ChewingKey * key, ChewingKeyRest * rest, - const char * str, int len) const { - - /* lookup divided table */ - size_t k; - const divided_table_item_t * item = NULL; - for (k = 0; k < G_N_ELEMENTS(divided_table); ++k) { - item = divided_table + k; - - const char * onepinyin = str + rest->m_raw_begin; - size_t len = strlen(item->m_orig_key); - - if (rest->length() != len) - continue; - - if (0 == strncmp(onepinyin, item->m_orig_key, len)) - break; - } - - /* found the match */ - if (k < G_N_ELEMENTS(divided_table)) { - /* do divided */ - item = divided_table + k; - return item; - } - - return NULL; -} - - -const resplit_table_item_t * FullPinyinParser2::retrieve_resplit_item_by_original_pinyins -(pinyin_option_t options, - ChewingKey * cur_key, ChewingKeyRest * cur_rest, - ChewingKey * next_key, ChewingKeyRest * next_rest, - const char * str, int len) const{ - /* lookup re-split table */ - size_t k; - const resplit_table_item_t * item = NULL; - - for (k = 0; k < G_N_ELEMENTS(resplit_table); ++k) { - item = resplit_table + k; - - const char * onepinyin = str + cur_rest->m_raw_begin; - size_t len = strlen(item->m_orig_keys[0]); - - if (cur_rest->length() != len) - continue; - - if (0 != strncmp(onepinyin, item->m_orig_keys[0], len)) - continue; - - onepinyin = str + next_rest->m_raw_begin; - len = strlen(item->m_orig_keys[1]); - - if (next_rest->length() != len) - continue; - - if (0 == strncmp(onepinyin, item->m_orig_keys[1], len)) - break; - } - - /* found the match */ - if (k < G_N_ELEMENTS(resplit_table)) { - item = resplit_table + k; - return item; - } - - return NULL; -} - -const resplit_table_item_t * FullPinyinParser2::retrieve_resplit_item_by_resplit_pinyins -(pinyin_option_t options, - ChewingKey * cur_key, ChewingKeyRest * cur_rest, - ChewingKey * next_key, ChewingKeyRest * next_rest, - const char * str, int len) const { - /* lookup divide table */ - size_t k; - const resplit_table_item_t * item = NULL; - - for (k = 0; k < G_N_ELEMENTS(resplit_table); ++k) { - item = resplit_table + k; - - const char * onepinyin = str + cur_rest->m_raw_begin; - size_t len = strlen(item->m_new_keys[0]); - - if (cur_rest->length() != len) - continue; - - if (0 != strncmp(onepinyin, item->m_new_keys[0], len)) - continue; - - onepinyin = str + next_rest->m_raw_begin; - len = strlen(item->m_new_keys[1]); - - if (next_rest->length() != len) - continue; - - if (0 == strncmp(onepinyin, item->m_new_keys[1], len)) - break; - } - - /* found the match */ - if (k < G_N_ELEMENTS(resplit_table)) { - item = resplit_table + k; - return item; - } - - return NULL; -} - -#endif - #define IS_KEY(x) (('a' <= x && x <= 'z') || x == ';') bool DoublePinyinParser2::parse_one_key(pinyin_option_t options, -- cgit