diff options
author | Peng Wu <alexepico@gmail.com> | 2012-02-17 10:54:45 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2012-02-17 10:54:45 +0800 |
commit | 36035361995fea3f44f1e1f78a9ac4aabf94290d (patch) | |
tree | 18406f23dfad66346c430ab3b0888dbce0105042 /src/storage | |
parent | a9fb045cae4df38786b12b4c66f316be5a0ee128 (diff) | |
download | libpinyin-36035361995fea3f44f1e1f78a9ac4aabf94290d.tar.gz libpinyin-36035361995fea3f44f1e1f78a9ac4aabf94290d.tar.xz libpinyin-36035361995fea3f44f1e1f78a9ac4aabf94290d.zip |
add comments for full pinyin parser2
Diffstat (limited to 'src/storage')
-rw-r--r-- | src/storage/pinyin_parser2.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/storage/pinyin_parser2.cpp b/src/storage/pinyin_parser2.cpp index defc9fe..f3b6240 100644 --- a/src/storage/pinyin_parser2.cpp +++ b/src/storage/pinyin_parser2.cpp @@ -374,25 +374,35 @@ int FullPinyinParser2::parse (pinyin_option_t options, ChewingKeyVector & keys, value.m_last_step = m; /* save next step */ + /* no previous result */ if (-1 == nextstep->m_last_step) *nextstep = value; + /* prefer the longest pinyin */ if (value.m_parsed_len > nextstep->m_parsed_len) *nextstep = value; + /* prefer the shortest keys with the same pinyin length */ if (value.m_parsed_len == nextstep->m_parsed_len && value.m_num_keys < nextstep->m_num_keys) *nextstep = value; + /* 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) { - /* "kaneiji" -> "ka'nei'ji" */ + /* prefer the complete pinyin with shengmu + * over without shengmu, + * ex: "kaneiji" -> "ka'nei'ji". + */ if ((value.m_key.m_initial != CHEWING_ZERO_INITIAL && !(value.m_key.m_middle == CHEWING_ZERO_MIDDLE && value.m_key.m_final == CHEWING_ZERO_FINAL)) && nextstep->m_key.m_initial == CHEWING_ZERO_INITIAL) *nextstep = value; - /* "xierqi" -> "xi'er'qi." */ + /* prefer the complete pinyin 'er' + * over the in-complete pinyin 'r', + * ex: "xierqi" -> "xi'er'qi." + */ if ((value.m_key.m_initial == CHEWING_ZERO_INITIAL && value.m_key.m_middle == CHEWING_ZERO_MIDDLE && value.m_key.m_final == CHEWING_ER) && @@ -401,7 +411,9 @@ int FullPinyinParser2::parse (pinyin_option_t options, ChewingKeyVector & keys, nextstep->m_key.m_final == CHEWING_ZERO_FINAL)) *nextstep = value; - /* "zheyanga$" -> "zhe'yang'a$" */ + /* 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) && |