diff options
Diffstat (limited to 'src/storage')
-rw-r--r-- | src/storage/pinyin_parser2.cpp | 27 | ||||
-rw-r--r-- | src/storage/zhuyin_custom2.h | 29 |
2 files changed, 41 insertions, 15 deletions
diff --git a/src/storage/pinyin_parser2.cpp b/src/storage/pinyin_parser2.cpp index 32cee92..6fe8a19 100644 --- a/src/storage/pinyin_parser2.cpp +++ b/src/storage/pinyin_parser2.cpp @@ -267,6 +267,12 @@ bool FullPinyinParser2::parse_one_key (pinyin_option_t options, parsed_len --; tone_pos = parsed_len; } + + /* check the force tone option. */ + if (options & FORCE_TONE && CHEWING_ZERO_TONE == tone) { + g_free(input); + return false; + } } /* parse pinyin core staff here. */ @@ -558,6 +564,10 @@ bool ChewingSimpleParser2::parse_one_key(pinyin_option_t options, /* remove tone from input */ if (search_chewing_tones(m_tone_table, ch, &tone)) symbols_len --; + + /* check the force tone option */ + if (options & FORCE_TONE && CHEWING_ZERO_TONE == tone) + return false; } int i; @@ -630,14 +640,23 @@ bool ChewingDiscreteParser2::parse_one_key(pinyin_option_t options, index++; } - if (index == len) + if (index == len) { + /* check the force tone option. */ + if (options & USE_TONE && options & FORCE_TONE) + return false; goto probe; + } /* probe tone */ if (options & USE_TONE) { if (search_chewing_tones(m_tone_table, str[index], &tone)) { index ++; } + + /* check the force tone option. */ + if (options & FORCE_TONE && CHEWING_ZERO_TONE == tone) { + return false; + } } probe: @@ -844,6 +863,12 @@ bool ChewingDaChenCP26Parser2::parse_one_key(pinyin_option_t options, /* remove tone from input */ if (search_chewing_tones(m_tone_table, ch, &tone)) len --; + + /* check the force tone option. */ + if (options & FORCE_TONE && CHEWING_ZERO_TONE == tone) { + g_free(input); + return false; + } } if (0 == len) diff --git a/src/storage/zhuyin_custom2.h b/src/storage/zhuyin_custom2.h index aa6dfb7..671a137 100644 --- a/src/storage/zhuyin_custom2.h +++ b/src/storage/zhuyin_custom2.h @@ -35,9 +35,10 @@ enum PinyinTableFlag{ PINYIN_INCOMPLETE = 1U << 3, CHEWING_INCOMPLETE = 1U << 4, USE_TONE = 1U << 5, - HSU_CORRECT = 1U << 6, - ETEN26_CORRECT = 1U << 7, - DYNAMIC_ADJUST = 1U << 8, + FORCE_TONE = 1U << 6, + HSU_CORRECT = 1U << 7, + ETEN26_CORRECT = 1U << 8, + DYNAMIC_ADJUST = 1U << 9, CHEWING_CORRECT_ALL = HSU_CORRECT|ETEN26_CORRECT }; @@ -48,17 +49,17 @@ enum PinyinTableFlag{ * */ enum PinyinAmbiguity2{ - PINYIN_AMB_C_CH = 1U << 9, - PINYIN_AMB_S_SH = 1U << 10, - PINYIN_AMB_Z_ZH = 1U << 11, - PINYIN_AMB_F_H = 1U << 12, - PINYIN_AMB_G_K = 1U << 13, - PINYIN_AMB_L_N = 1U << 14, - PINYIN_AMB_L_R = 1U << 15, - PINYIN_AMB_AN_ANG = 1U << 16, - PINYIN_AMB_EN_ENG = 1U << 17, - PINYIN_AMB_IN_ING = 1U << 18, - PINYIN_AMB_ALL = 0x3FFU << 9 + PINYIN_AMB_C_CH = 1U << 12, + PINYIN_AMB_S_SH = 1U << 13, + PINYIN_AMB_Z_ZH = 1U << 14, + PINYIN_AMB_F_H = 1U << 15, + PINYIN_AMB_G_K = 1U << 16, + PINYIN_AMB_L_N = 1U << 17, + PINYIN_AMB_L_R = 1U << 18, + PINYIN_AMB_AN_ANG = 1U << 19, + PINYIN_AMB_EN_ENG = 1U << 20, + PINYIN_AMB_IN_ING = 1U << 21, + PINYIN_AMB_ALL = 0x3FFU << 12 }; /** |