diff options
author | Peng Wu <alexepico@gmail.com> | 2015-06-16 10:45:57 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2015-06-16 10:45:57 +0800 |
commit | a08ea7202399af9f077c23418554956cf83e489d (patch) | |
tree | 5249cfd1c916c7746725557de422457c3f3d5833 | |
parent | db2781ac9ffca8d2fa818af616b8da92c6eeb1f9 (diff) | |
download | libzhuyin-a08ea7202399af9f077c23418554956cf83e489d.tar.gz libzhuyin-a08ea7202399af9f077c23418554956cf83e489d.tar.xz libzhuyin-a08ea7202399af9f077c23418554956cf83e489d.zip |
fixes first tone
-rw-r--r-- | src/storage/pinyin_parser2.cpp | 6 | ||||
-rw-r--r-- | src/storage/pinyin_parser2.h | 4 | ||||
-rw-r--r-- | utils/storage/gen_zhuyin_table.cpp | 4 |
3 files changed, 11 insertions, 3 deletions
diff --git a/src/storage/pinyin_parser2.cpp b/src/storage/pinyin_parser2.cpp index f78653f..bdbe385 100644 --- a/src/storage/pinyin_parser2.cpp +++ b/src/storage/pinyin_parser2.cpp @@ -132,6 +132,9 @@ gchar * _ChewingKey::get_bopomofo_string() { if (CHEWING_ZERO_TONE == m_tone) { return g_strdup(item.m_bopomofo); + } else if (CHEWING_1 == m_tone) { + /* for first tone, usually not display it. */ + return g_strdup(item.m_bopomofo); } else { return g_strdup_printf("%s%s", item.m_bopomofo, chewing_tone_table[m_tone]); @@ -1263,7 +1266,8 @@ bool ChewingDirectParser2::parse_one_key(pinyin_option_t options, ChewingKey & key, const char *str, int len) const { options &= ~ZHUYIN_AMB_ALL; - unsigned char tone = CHEWING_ZERO_TONE; + /* by default, chewing will use the first tone. */ + unsigned char tone = CHEWING_1; if (0 == len) return false; diff --git a/src/storage/pinyin_parser2.h b/src/storage/pinyin_parser2.h index 72635c0..9b9d78e 100644 --- a/src/storage/pinyin_parser2.h +++ b/src/storage/pinyin_parser2.h @@ -388,8 +388,12 @@ inline int pinyin_compare_middle_and_final2(pinyin_option_t options, inline int pinyin_compare_tone2(pinyin_option_t options, ChewingTone lhs, ChewingTone rhs) { +#if 0 if (lhs == rhs) return 0; +#endif + if (options & FORCE_TONE) + return (lhs - rhs); if (lhs == CHEWING_ZERO_TONE) return 0; if (rhs == CHEWING_ZERO_TONE) diff --git a/utils/storage/gen_zhuyin_table.cpp b/utils/storage/gen_zhuyin_table.cpp index 2620ed1..87bc591 100644 --- a/utils/storage/gen_zhuyin_table.cpp +++ b/utils/storage/gen_zhuyin_table.cpp @@ -188,7 +188,7 @@ void feed_line(const char * phrase, const char * pinyin, const guint32 freq) { ChewingKeyRestVector key_rests = g_array_new (FALSE, FALSE, sizeof(ChewingKeyRest)); - pinyin_option_t options = USE_TONE; + pinyin_option_t options = USE_TONE | FORCE_TONE; parser.parse(options, keys, key_rests, pinyin, strlen(pinyin)); assert(keys->len == key_rests->len); @@ -308,7 +308,7 @@ void gen_phrase_file(const char * outputfile, int phrase_index){ ChewingKeyRest key_rest = g_array_index (key_rests, ChewingKeyRest, k); - //assert (CHEWING_ZERO_TONE != key.m_tone); + assert (CHEWING_ZERO_TONE != key.m_tone); pinyin = key.get_bopomofo_string(); g_array_append_val(pinyins, pinyin); } |