diff options
author | Peng Wu <alexepico@gmail.com> | 2017-05-25 15:23:33 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2017-05-25 15:23:33 +0800 |
commit | 0bd9779cfd4be55ec600355c31806279885ba754 (patch) | |
tree | ca89d07048c9bd07d1692b8c25a7a87c8a1143af /src/storage/phrase_index.cpp | |
parent | 132a15bb1da8bc426cb4abf796814f4ec307bccd (diff) | |
download | libpinyin-0bd9779cfd4be55ec600355c31806279885ba754.tar.gz libpinyin-0bd9779cfd4be55ec600355c31806279885ba754.tar.xz libpinyin-0bd9779cfd4be55ec600355c31806279885ba754.zip |
handle zhuyin table file in src/storage
Diffstat (limited to 'src/storage/phrase_index.cpp')
-rw-r--r-- | src/storage/phrase_index.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/storage/phrase_index.cpp b/src/storage/phrase_index.cpp index f1b1a75..c4a7286 100644 --- a/src/storage/phrase_index.cpp +++ b/src/storage/phrase_index.cpp @@ -511,7 +511,8 @@ bool SubPhraseIndex::merge(PhraseIndexLogger * logger){ return true; } -bool FacadePhraseIndex::load_text(guint8 phrase_index, FILE * infile){ +bool FacadePhraseIndex::load_text(guint8 phrase_index, FILE * infile, + TABLE_PHONETIC_TYPE type){ SubPhraseIndex * & sub_phrases = m_sub_phrase_indices[phrase_index]; if ( !sub_phrases ){ sub_phrases = new SubPhraseIndex; @@ -554,14 +555,26 @@ bool FacadePhraseIndex::load_text(guint8 phrase_index, FILE * infile){ item_ptr->set_phrase_string(written, phrase_ucs4); } - pinyin_option_t options = USE_TONE; - PinyinDirectParser2 parser; ChewingKeyVector keys = g_array_new(FALSE, FALSE, sizeof(ChewingKey)); ChewingKeyRestVector key_rests = g_array_new(FALSE, FALSE, sizeof(ChewingKeyRest)); - parser.parse(options, keys, key_rests, pinyin, strlen(pinyin)); - + switch (type) { + case PINYIN_TABLE: { + PinyinDirectParser2 parser; + pinyin_option_t options = USE_TONE; + parser.parse(options, keys, key_rests, pinyin, strlen(pinyin)); + break; + } + + case ZHUYIN_TABLE: { + ZhuyinDirectParser2 parser; + pinyin_option_t options = USE_TONE | FORCE_TONE; + parser.parse(options, keys, key_rests, pinyin, strlen(pinyin)); + break; + } + }; + if (item_ptr->get_phrase_length() == keys->len) { item_ptr->add_pronunciation((ChewingKey *)keys->data, freq); } else { |