From 3c89c1aa4c818205cf2e871b932b1f4f0fe3fb21 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Wed, 14 Oct 2015 11:03:57 +0800 Subject: update FullPinyinParser2 --- src/storage/Makefile.am | 1 + src/storage/pinyin_parser2.cpp | 20 ++++++++++++++++++++ src/storage/pinyin_parser2.h | 3 +++ src/storage/zhuyin_parser2.cpp | 21 --------------------- 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/storage/Makefile.am b/src/storage/Makefile.am index f898973..7698e12 100644 --- a/src/storage/Makefile.am +++ b/src/storage/Makefile.am @@ -59,6 +59,7 @@ libstorage_la_SOURCES = phrase_index.cpp \ ngram.cpp \ tag_utility.cpp \ pinyin_parser2.cpp \ + zhuyin_parser2.cpp \ chewing_large_table.cpp \ table_info.cpp diff --git a/src/storage/pinyin_parser2.cpp b/src/storage/pinyin_parser2.cpp index d3442ee..a5c3985 100644 --- a/src/storage/pinyin_parser2.cpp +++ b/src/storage/pinyin_parser2.cpp @@ -438,6 +438,26 @@ int FullPinyinParser2::final_step(size_t step_len, ChewingKeyVector & keys, return parsed_len; } +bool FullPinyinParser2::set_scheme(ZhuyinScheme scheme){ + switch(scheme){ + case FULL_PINYIN_HANYU: + m_pinyin_index = hanyu_pinyin_index; + m_pinyin_index_len = G_N_ELEMENTS(hanyu_pinyin_index); + break; + case FULL_PINYIN_LUOMA: + m_pinyin_index = luoma_pinyin_index; + m_pinyin_index_len = G_N_ELEMENTS(luoma_pinyin_index); + break; + case FULL_PINYIN_SECONDARY_BOPOMOFO: + m_pinyin_index = secondary_bopomofo_index; + m_pinyin_index_len = G_N_ELEMENTS(secondary_bopomofo_index); + break; + default: + assert(false); + } + return true; +} + bool FullPinyinParser2::post_process2(pinyin_option_t options, ChewingKeyVector & keys, ChewingKeyRestVector & key_rests, diff --git a/src/storage/pinyin_parser2.h b/src/storage/pinyin_parser2.h index 9a9679f..40d96bb 100644 --- a/src/storage/pinyin_parser2.h +++ b/src/storage/pinyin_parser2.h @@ -186,6 +186,9 @@ public: * the parse method will use dynamic programming to drive parse_one_key. */ virtual int parse(pinyin_option_t options, ChewingKeyVector & keys, ChewingKeyRestVector & key_rests, const char *str, int len) const; + +public: + bool set_scheme(ZhuyinScheme scheme); }; diff --git a/src/storage/zhuyin_parser2.cpp b/src/storage/zhuyin_parser2.cpp index 32a519f..946dbb0 100644 --- a/src/storage/zhuyin_parser2.cpp +++ b/src/storage/zhuyin_parser2.cpp @@ -89,28 +89,7 @@ static inline bool search_chewing_index(pinyin_option_t options, } -bool FullPinyinParser2::set_scheme(ZhuyinScheme scheme){ - switch(scheme){ - case FULL_PINYIN_HANYU: - m_pinyin_index = hanyu_pinyin_index; - m_pinyin_index_len = G_N_ELEMENTS(hanyu_pinyin_index); - break; - case FULL_PINYIN_LUOMA: - m_pinyin_index = luoma_pinyin_index; - m_pinyin_index_len = G_N_ELEMENTS(luoma_pinyin_index); - break; - case FULL_PINYIN_SECONDARY_BOPOMOFO: - m_pinyin_index = secondary_bopomofo_index; - m_pinyin_index_len = G_N_ELEMENTS(secondary_bopomofo_index); - break; - default: - assert(false); - } - return true; -} - /* the chewing string must be freed with g_free. */ - static bool search_chewing_symbols(const chewing_symbol_item_t * symbol_table, const char key, const char ** chewing) { *chewing = ""; -- cgit