diff options
author | Peng Wu <alexepico@gmail.com> | 2013-09-13 10:48:44 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2013-09-13 11:37:37 +0800 |
commit | ab3560ff41d0b93c0ffbec9ea9dbf121dad639f4 (patch) | |
tree | 62bcf546077dce6bc99accdf77e48b0c27509246 /src | |
parent | 23a6259ae58fe293b7d1e69439d9c1590027e26e (diff) | |
download | libzhuyin-ab3560ff41d0b93c0ffbec9ea9dbf121dad639f4.tar.gz libzhuyin-ab3560ff41d0b93c0ffbec9ea9dbf121dad639f4.tar.xz libzhuyin-ab3560ff41d0b93c0ffbec9ea9dbf121dad639f4.zip |
write in_chewing_scheme
Diffstat (limited to 'src')
-rw-r--r-- | src/storage/pinyin_custom2.h | 3 | ||||
-rw-r--r-- | src/storage/pinyin_parser2.cpp | 60 | ||||
-rw-r--r-- | src/storage/pinyin_parser2.h | 2 |
3 files changed, 59 insertions, 6 deletions
diff --git a/src/storage/pinyin_custom2.h b/src/storage/pinyin_custom2.h index 679e8c0..2c72260 100644 --- a/src/storage/pinyin_custom2.h +++ b/src/storage/pinyin_custom2.h @@ -37,7 +37,8 @@ enum PinyinTableFlag{ USE_TONE = 1U << 5, HSU_CORRECT = 1U << 6, ETEN26_CORRECT = 1U << 7, - DYNAMIC_ADJUST = 1U << 8 + DYNAMIC_ADJUST = 1U << 8, + CHEWING_CORRECT_ALL = HSU_CORRECT|ETEN26_CORRECT }; /** diff --git a/src/storage/pinyin_parser2.cpp b/src/storage/pinyin_parser2.cpp index 079af34..98817d9 100644 --- a/src/storage/pinyin_parser2.cpp +++ b/src/storage/pinyin_parser2.cpp @@ -69,6 +69,15 @@ static bool check_chewing_options(pinyin_option_t options, const chewing_index_i return false; } + /* handle correct chewing, currently only one flag per item. */ + flags &= CHEWING_CORRECT_ALL; + options &= CHEWING_CORRECT_ALL; + + if (flags) { + if ((flags & options) != flags) + return false; + } + return true; } @@ -464,8 +473,7 @@ static bool search_chewing_tones(const chewing_tone_item_t * tone_table, bool ChewingSimpleParser2::parse_one_key(pinyin_option_t options, ChewingKey & key, - const char *str, int len) const { - /* options &= ~(PINYIN_CORRECT_ALL|PINYIN_AMB_ALL); */ + const char * str, int len) const { options &= ~PINYIN_AMB_ALL; char tone = CHEWING_ZERO_TONE; @@ -583,8 +591,7 @@ bool ChewingSimpleParser2::set_scheme(ChewingScheme scheme) { bool ChewingSimpleParser2::in_chewing_scheme(pinyin_option_t options, const char key, - const char ** symbol) - const { + const char ** symbol) const { const gchar * chewing = NULL; char tone = CHEWING_ZERO_TONE; @@ -605,3 +612,48 @@ bool ChewingSimpleParser2::in_chewing_scheme(pinyin_option_t options, return false; } + +bool ChewingDiscreteParser2::parse_one_key(pinyin_option_t options, + ChewingKey & key, + const char * str, int len) const { + int index = 0; + options &= ~PINYIN_AMB_ALL; + char tone = CHEWING_ZERO_TONE; + +} + +bool ChewingDiscreteParser2::in_chewing_scheme(pinyin_option_t options, + const char key, + const char ** symbol) const { + const gchar * chewing = NULL; + char tone = CHEWING_ZERO_TONE; + + if (search_chewing_symbols(m_initial_table, key, &chewing)) { + if (symbol) + *symbol = chewing; + return true; + } + + if (search_chewing_symbols(m_middle_table, key, &chewing)) { + if (symbol) + *symbol = chewing; + return true; + } + + if (search_chewing_symbols(m_final_table, key, &chewing)) { + if (symbol) + *symbol = chewing; + return true; + } + + if (!(options & USE_TONE)) + return false; + + if (search_chewing_tones(m_tone_table, key, &tone)) { + if (symbol) + *symbol = chewing_tone_table[tone]; + return true; + } + + return false; +} diff --git a/src/storage/pinyin_parser2.h b/src/storage/pinyin_parser2.h index c342bad..b410de5 100644 --- a/src/storage/pinyin_parser2.h +++ b/src/storage/pinyin_parser2.h @@ -199,11 +199,11 @@ public: class ChewingDiscreteParser2 : public PhoneticParser2 { - /* Note: some internal pointers to chewing scheme table. */ protected: /* internal options for chewing parsing. */ pinyin_option_t m_options; + /* some internal pointers to chewing scheme table. */ const chewing_index_item_t * m_chewing_index; size_t m_chewing_index_len; const chewing_symbol_item_t * m_initial_table; |