From bc660fd1fd0c7b71848c7ad29afeefadf4761649 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Mon, 12 Oct 2015 15:50:44 +0800 Subject: update pinyin_parser2.* --- src/storage/pinyin_parser2.cpp | 26 +++++++++++++------------- src/storage/pinyin_parser2.h | 10 ++++++---- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/storage/pinyin_parser2.cpp b/src/storage/pinyin_parser2.cpp index d2377e6..60a50d0 100644 --- a/src/storage/pinyin_parser2.cpp +++ b/src/storage/pinyin_parser2.cpp @@ -31,7 +31,7 @@ #include "chewing_key.h" #include "pinyin_parser_table.h" #include "double_pinyin_table.h" -#include "chewing_table.h" +#include "zhuyin_table.h" using namespace pinyin; @@ -60,11 +60,11 @@ static bool check_pinyin_options(pinyin_option_t options, const pinyin_index_ite static bool check_chewing_options(pinyin_option_t options, const chewing_index_item_t * item) { guint32 flags = item->m_flags; - assert (flags & IS_CHEWING); + assert (flags & IS_ZHUYIN); /* handle incomplete chewing. */ - if (flags & CHEWING_INCOMPLETE) { - if (!(options & CHEWING_INCOMPLETE)) + if (flags & ZHUYIN_INCOMPLETE) { + if (!(options & ZHUYIN_INCOMPLETE)) return false; } @@ -115,9 +115,9 @@ gchar * _ChewingKey::get_chewing_string() { const content_table_item_t & item = content_table[index]; if (CHEWING_ZERO_TONE == m_tone) { - return g_strdup(item.m_chewing_str); + return g_strdup(item.m_zhuyin_str); } else { - return g_strdup_printf("%s%s", item.m_chewing_str, + return g_strdup_printf("%s%s", item.m_zhuyin_str, chewing_tone_table[m_tone]); } } @@ -197,7 +197,7 @@ static inline bool search_chewing_index(pinyin_option_t options, std_lite::pair range; range = std_lite::equal_range - (chewing_index, chewing_index + G_N_ELEMENTS(chewing_index), + (zhuyin_index, zhuyin_index + G_N_ELEMENTS(zhuyin_index), item, compare_chewing_less_than); guint16 range_len = range.second - range.first; @@ -659,7 +659,7 @@ bool DoublePinyinParser2::parse_one_key(pinyin_option_t options, } ChewingTone tone = CHEWING_ZERO_TONE; - options &= ~(PINYIN_INCOMPLETE|CHEWING_INCOMPLETE); + options &= ~(PINYIN_INCOMPLETE|ZHUYIN_INCOMPLETE); options |= PINYIN_CORRECT_UE_VE | PINYIN_CORRECT_V_U; /* parse tone */ @@ -940,21 +940,21 @@ int ChewingParser2::parse(pinyin_option_t options, ChewingKeyVector & keys, } -bool ChewingParser2::set_scheme(ChewingScheme scheme) { +bool ChewingParser2::set_scheme(ZhuyinScheme scheme) { switch(scheme) { - case CHEWING_STANDARD: + case ZHUYIN_STANDARD: m_symbol_table = chewing_standard_symbols; m_tone_table = chewing_standard_tones; return true; - case CHEWING_IBM: + case ZHUYIN_IBM: m_symbol_table = chewing_ibm_symbols; m_tone_table = chewing_ibm_tones; return true; - case CHEWING_GINYIEH: + case ZHUYIN_GINYIEH: m_symbol_table = chewing_ginyieh_symbols; m_tone_table = chewing_ginyieh_tones; return true; - case CHEWING_ETEN: + case ZHUYIN_ETEN: m_symbol_table = chewing_eten_symbols; m_tone_table = chewing_eten_tones; return true; diff --git a/src/storage/pinyin_parser2.h b/src/storage/pinyin_parser2.h index edf4764..e8f01cd 100644 --- a/src/storage/pinyin_parser2.h +++ b/src/storage/pinyin_parser2.h @@ -33,7 +33,9 @@ typedef struct { const char * m_pinyin_str; const char * m_shengmu_str; const char * m_yunmu_str; - const char * m_chewing_str; + const char * m_zhuyin_str; + const char * m_luoma_pinyin_str; + const char * m_secondary_zhuyin_str; ChewingKey m_chewing_key; } content_table_item_t; @@ -240,7 +242,7 @@ protected: public: ChewingParser2() { m_symbol_table = NULL; m_tone_table = NULL; - set_scheme(CHEWING_DEFAULT); + set_scheme(ZHUYIN_DEFAULT); } virtual ~ChewingParser2() {} @@ -250,7 +252,7 @@ public: virtual int parse(pinyin_option_t options, ChewingKeyVector & keys, ChewingKeyRestVector & key_rests, const char *str, int len) const; public: - bool set_scheme(ChewingScheme scheme); + bool set_scheme(ZhuyinScheme scheme); bool in_chewing_scheme(pinyin_option_t options, const char key, const char ** symbol) const; }; @@ -310,7 +312,7 @@ inline int pinyin_compare_middle_and_final2(pinyin_option_t options, return 0; /* both pinyin and chewing incomplete options will enable this. */ - if (options & (PINYIN_INCOMPLETE | CHEWING_INCOMPLETE)) { + if (options & (PINYIN_INCOMPLETE | ZHUYIN_INCOMPLETE)) { if (middle_lhs == CHEWING_ZERO_MIDDLE && final_lhs == CHEWING_ZERO_FINAL) return 0; -- cgit