summaryrefslogtreecommitdiffstats
path: root/src/storage/pinyin_parser2.cpp
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2013-09-13 10:48:44 +0800
committerPeng Wu <alexepico@gmail.com>2013-09-13 11:37:37 +0800
commitab3560ff41d0b93c0ffbec9ea9dbf121dad639f4 (patch)
tree62bcf546077dce6bc99accdf77e48b0c27509246 /src/storage/pinyin_parser2.cpp
parent23a6259ae58fe293b7d1e69439d9c1590027e26e (diff)
downloadlibzhuyin-ab3560ff41d0b93c0ffbec9ea9dbf121dad639f4.tar.gz
libzhuyin-ab3560ff41d0b93c0ffbec9ea9dbf121dad639f4.tar.xz
libzhuyin-ab3560ff41d0b93c0ffbec9ea9dbf121dad639f4.zip
write in_chewing_scheme
Diffstat (limited to 'src/storage/pinyin_parser2.cpp')
-rw-r--r--src/storage/pinyin_parser2.cpp60
1 files changed, 56 insertions, 4 deletions
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;
+}