From 0030a2639d96eaa93fd6ed5a416f96f3036e4a6e Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Tue, 13 Oct 2015 16:16:47 +0800 Subject: init fallback tables --- src/storage/pinyin_parser2.cpp | 17 +++++++++++------ src/storage/pinyin_parser2.h | 14 +++++++++----- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/storage/pinyin_parser2.cpp b/src/storage/pinyin_parser2.cpp index 85988e6..f6ac4c9 100644 --- a/src/storage/pinyin_parser2.cpp +++ b/src/storage/pinyin_parser2.cpp @@ -799,11 +799,14 @@ int DoublePinyinParser2::parse(pinyin_option_t options, ChewingKeyVector & keys, #undef IS_KEY bool DoublePinyinParser2::set_scheme(DoublePinyinScheme scheme) { + /* most double pinyin schemes doesn't use fallback table. */ + m_fallback_table = NULL; switch (scheme) { case DOUBLE_PINYIN_ZRM: - m_shengmu_table = double_pinyin_zrm_sheng; - m_yunmu_table = double_pinyin_zrm_yun; + m_shengmu_table = double_pinyin_zrm_sheng; + m_yunmu_table = double_pinyin_zrm_yun; + m_fallback_table = double_pinyin_zrm_fallback; return true; case DOUBLE_PINYIN_MS: m_shengmu_table = double_pinyin_mspy_sheng; @@ -818,12 +821,14 @@ bool DoublePinyinParser2::set_scheme(DoublePinyinScheme scheme) { m_yunmu_table = double_pinyin_abc_yun; return true; case DOUBLE_PINYIN_PYJJ: - m_shengmu_table = double_pinyin_pyjj_sheng; - m_yunmu_table = double_pinyin_pyjj_yun; + m_shengmu_table = double_pinyin_pyjj_sheng; + m_yunmu_table = double_pinyin_pyjj_yun; + m_fallback_table = double_pinyin_pyjj_fallback; return true; case DOUBLE_PINYIN_XHE: - m_shengmu_table = double_pinyin_xhe_sheng; - m_yunmu_table = double_pinyin_xhe_yun; + m_shengmu_table = double_pinyin_xhe_sheng; + m_yunmu_table = double_pinyin_xhe_yun; + m_fallback_table = double_pinyin_xhe_fallback; return true; case DOUBLE_PINYIN_CUSTOMIZED: assert(FALSE); diff --git a/src/storage/pinyin_parser2.h b/src/storage/pinyin_parser2.h index f490411..39268d8 100644 --- a/src/storage/pinyin_parser2.h +++ b/src/storage/pinyin_parser2.h @@ -195,18 +195,22 @@ public: * Parse the double pinyin string into an array of struct ChewingKeys. * */ -/* The valid input chars of ShuangPin is a-z and ';' +/* The valid input chars of double pinyin is a-z and ';' */ class DoublePinyinParser2 : public PhoneticParser2 { - /* Note: two internal pointers to double pinyin scheme table. */ + /* Note: three internal pointers to double pinyin scheme table. */ protected: - const double_pinyin_scheme_shengmu_item_t * m_shengmu_table; - const double_pinyin_scheme_yunmu_item_t * m_yunmu_table; + const double_pinyin_scheme_shengmu_item_t * m_shengmu_table; + const double_pinyin_scheme_yunmu_item_t * m_yunmu_table; + const double_pinyin_scheme_fallback_item_t * m_fallback_table; public: DoublePinyinParser2() { - m_shengmu_table = NULL; m_yunmu_table = NULL; + m_shengmu_table = NULL; + m_yunmu_table = NULL; + m_fallback_table = NULL; + set_scheme(DOUBLE_PINYIN_DEFAULT); } -- cgit