From 865dd14c83d9ad6fedb523181e2f066ed6b9dff3 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Mon, 17 Aug 2020 12:35:35 +0800 Subject: improve full pinyin parser --- src/storage/pinyin_parser2.cpp | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/storage/pinyin_parser2.cpp b/src/storage/pinyin_parser2.cpp index 9e8d2f9..0ac9bc7 100644 --- a/src/storage/pinyin_parser2.cpp +++ b/src/storage/pinyin_parser2.cpp @@ -306,22 +306,25 @@ int FullPinyinParser2::parse (pinyin_option_t options, ChewingKeyVector & keys, /* handle with the same pinyin length and the number of keys */ if (value.m_parsed_len == nextstep->m_parsed_len && value.m_num_keys == nextstep->m_num_keys && - value.m_distance < nextstep->m_distance) { + value.m_distance < nextstep->m_distance) *nextstep = value; -#if 0 - /* prefer the 'a' at the end of clause, - * ex: "zheyanga$" -> "zhe'yang'a$". - */ - if (value.m_parsed_len == len && - (nextstep->m_key.m_initial != CHEWING_ZERO_INITIAL && - nextstep->m_key.m_final == CHEWING_A) && - (value.m_key.m_initial == CHEWING_ZERO_INITIAL && - value.m_key.m_middle == CHEWING_ZERO_MIDDLE && - value.m_key.m_final == CHEWING_A)) - *nextstep = value; +#if 1 + /* prefer the 'a' at the end of clause, + * ex: "zheyanga$" -> "zhe'yang'a$". + */ + if (value.m_parsed_len == len && + (value.m_parsed_len == nextstep->m_parsed_len && + value.m_num_keys == nextstep->m_num_keys && + value.m_distance == nextstep->m_distance) && + (nextstep->m_key.m_initial != CHEWING_ZERO_INITIAL && + nextstep->m_key.m_middle == CHEWING_ZERO_MIDDLE && + nextstep->m_key.m_final == CHEWING_A) && + (value.m_key.m_initial == CHEWING_ZERO_INITIAL && + value.m_key.m_middle == CHEWING_ZERO_MIDDLE && + value.m_key.m_final == CHEWING_A)) + *nextstep = value; #endif - } } } } -- cgit