diff options
author | Peng Wu <alexepico@gmail.com> | 2014-03-13 14:46:42 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2014-03-13 14:50:09 +0800 |
commit | 65d61cda3f2f3a46a6be2a535dbbc3ea6fed6063 (patch) | |
tree | f2c0dfd5294c5615d0226a469057ea1f17c0f14f | |
parent | 7c540af4894471116aadfed6a0b92d344938c1f0 (diff) | |
download | libzhuyin-65d61cda3f2f3a46a6be2a535dbbc3ea6fed6063.tar.gz libzhuyin-65d61cda3f2f3a46a6be2a535dbbc3ea6fed6063.tar.xz libzhuyin-65d61cda3f2f3a46a6be2a535dbbc3ea6fed6063.zip |
add the force tone option
-rw-r--r-- | src/storage/pinyin_parser2.cpp | 27 | ||||
-rw-r--r-- | src/storage/zhuyin_custom2.h | 29 | ||||
-rw-r--r-- | src/zhuyin.h | 1 |
3 files changed, 42 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 }; /** diff --git a/src/zhuyin.h b/src/zhuyin.h index d69a828..3b5341c 100644 --- a/src/zhuyin.h +++ b/src/zhuyin.h @@ -656,6 +656,7 @@ bool zhuyin_get_phrase_token(zhuyin_instance_t * instance, /* hack here. */ typedef ChewingKey PinyinKey; typedef ChewingKeyRest PinyinKeyPos; +typedef pinyin_option_t zhuyin_option_t; G_END_DECLS |