summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2013-01-25 12:16:19 +0800
committerPeng Wu <alexepico@gmail.com>2013-01-26 10:33:19 +0800
commit6e42ca426e6411bb7d6b5e09b35ea578cf8ca124 (patch)
treef51d1dd866bc3251ecfba0975c48a2f6d02f71d4
parent3bcd9383c18468c4a34feae7ce2cf48578f93d61 (diff)
downloadlibpinyin-6e42ca426e6411bb7d6b5e09b35ea578cf8ca124.tar.gz
libpinyin-6e42ca426e6411bb7d6b5e09b35ea578cf8ca124.tar.xz
libpinyin-6e42ca426e6411bb7d6b5e09b35ea578cf8ca124.zip
fixes incomplete pinyin
-rw-r--r--src/storage/pinyin_phrase2.h22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/storage/pinyin_phrase2.h b/src/storage/pinyin_phrase2.h
index ba658f0..d5042aa 100644
--- a/src/storage/pinyin_phrase2.h
+++ b/src/storage/pinyin_phrase2.h
@@ -132,6 +132,10 @@ inline void compute_lower_value2(pinyin_option_t options,
* to check lower bound.
*/
+ /* as chewing zero middle is the first item, and its value is zero,
+ * no need to adjust it for incomplete pinyin.
+ */
+
/* compute lower final */
sel = aKey.m_final;
for (k = aKey.m_final - 1; k >= CHEWING_ZERO_FINAL; --k) {
@@ -183,10 +187,20 @@ inline void compute_upper_value2(pinyin_option_t options,
}
aKey.m_initial = (ChewingInitial)sel;
- /* compute upper middle, skipped as no fuzzy pinyin here.
- * if needed in future, still use pinyin_compare_middle_and_final2
- * to check upper bound.
- */
+ /* adjust it for incomplete pinyin. */
+
+ /* compute upper middle */
+ sel = aKey.m_middle;
+ for (k = aKey.m_middle + 1; k <= CHEWING_LAST_MIDDLE; ++k) {
+ if (0 != pinyin_compare_middle_and_final2
+ (options,
+ (ChewingMiddle)aKey.m_middle, (ChewingMiddle)k,
+ (ChewingFinal)aKey.m_final, (ChewingFinal)aKey.m_final))
+ break;
+ else
+ sel = k;
+ }
+ aKey.m_middle = (ChewingMiddle)sel;
/* compute upper final */
sel = aKey.m_final;