summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2012-01-12 12:30:19 +0800
committerPeng Wu <alexepico@gmail.com>2012-01-12 12:30:19 +0800
commit845f8ed78a9a1ffe2ac8adf7cdb111473bb997e4 (patch)
treeb00ea62f7c1e5bebea42abde1da0da0daeb90699 /src
parentee0b9cde31d362a95f514cbab043229940d04973 (diff)
downloadlibpinyin-845f8ed78a9a1ffe2ac8adf7cdb111473bb997e4.tar.gz
libpinyin-845f8ed78a9a1ffe2ac8adf7cdb111473bb997e4.tar.xz
libpinyin-845f8ed78a9a1ffe2ac8adf7cdb111473bb997e4.zip
update pinyin parser
Diffstat (limited to 'src')
-rw-r--r--src/storage/pinyin_parser2.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/storage/pinyin_parser2.cpp b/src/storage/pinyin_parser2.cpp
index ee43eaf..ceea641 100644
--- a/src/storage/pinyin_parser2.cpp
+++ b/src/storage/pinyin_parser2.cpp
@@ -299,10 +299,9 @@ int FullPinyinParser2::parse (pinyin_option_t options, ChewingKeyVector & keys,
next_sep = k;
}
- pinyin_option_t heuristic_options = options & ~PINYIN_CORRECT_ALL;
-
+#if 0
/* Heuristic Method:
- * do maximum forward match first, and without auto corrections. */
+ * do maximum forward match first. */
for (size_t pos = i; pos < next_sep; ++pos) {
curstep = &g_array_index(m_parse_steps, parse_value_t, pos);
size_t try_len = std_lite::min
@@ -317,7 +316,7 @@ int FullPinyinParser2::parse (pinyin_option_t options, ChewingKeyVector & keys,
ChewingKey key; ChewingKeyRest rest;
bool parsed = parse_one_key
- (heuristic_options, key, onepinyin, onepinyinlen);
+ (options, key, onepinyin, onepinyinlen);
rest.m_raw_begin = pos; rest.m_raw_end = n;
if (!parsed)
@@ -343,6 +342,7 @@ int FullPinyinParser2::parse (pinyin_option_t options, ChewingKeyVector & keys,
break;
}
}
+#endif
/* dynamic programming here. */
for (size_t m = i; m < next_sep; ++m) {
@@ -379,6 +379,9 @@ int FullPinyinParser2::parse (pinyin_option_t options, ChewingKeyVector & keys,
if (value.m_parsed_len == nextstep->m_parsed_len &&
value.m_num_keys < nextstep->m_num_keys)
*nextstep = value;
+ if (nextstep->m_key.m_initial == CHEWING_ZERO_INITIAL &&
+ value.m_key.m_initial != CHEWING_ZERO_INITIAL)
+ *nextstep = value;
}
}
}
@@ -489,8 +492,8 @@ bool FullPinyinParser2::post_process(pinyin_option_t options,
*cur_key = item->m_new_keys[0];
*next_key = item->m_new_keys[1];
/* assumes only moved one char in gen_all_resplit script. */
- cur_rest->m_raw_end --;
- next_rest->m_raw_begin --;
+ cur_rest->m_raw_end ++;
+ next_rest->m_raw_begin ++;
}
/* save back tones */