summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2012-09-10 16:11:42 +0800
committerPeng Wu <alexepico@gmail.com>2012-09-10 16:11:42 +0800
commit8ebdaf1f72ad559c9c1fab72ca22e978697e64c9 (patch)
treec244f09db0c3cb870a1f44ba82251b148285c8b2
parenteb63539270fab81678da97c292d247796bd5a367 (diff)
downloadlibpinyin-8ebdaf1f72ad559c9c1fab72ca22e978697e64c9.zip
libpinyin-8ebdaf1f72ad559c9c1fab72ca22e978697e64c9.tar.gz
libpinyin-8ebdaf1f72ad559c9c1fab72ca22e978697e64c9.tar.xz
fixes get_best_match
-rw-r--r--src/lookup/pinyin_lookup2.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/lookup/pinyin_lookup2.cpp b/src/lookup/pinyin_lookup2.cpp
index bb57295..8834a44 100644
--- a/src/lookup/pinyin_lookup2.cpp
+++ b/src/lookup/pinyin_lookup2.cpp
@@ -238,6 +238,9 @@ bool PinyinLookup2::get_best_match(TokenVector prefixes,
LookupStepContent step = (LookupStepContent)
g_ptr_array_index(m_steps_content, i);
+ populate_candidates(candidates, step);
+ get_top_results(topresults, candidates);
+
for ( int m = i + 1; m < nstep; ++m ){
const int len = m - i;
if (len > MAX_PHRASE_LENGTH)
@@ -253,11 +256,10 @@ bool PinyinLookup2::get_best_match(TokenVector prefixes,
/* do one pinyin table search. */
int result = m_pinyin_table->search(len, pinyin_keys + i, ranges);
- populate_candidates(candidates, step);
- get_top_results(topresults, candidates);
-
- search_bigram2(topresults, i, ranges),
- search_unigram2(topresults, i, ranges);
+ if (result & SEARCH_OK) {
+ search_bigram2(topresults, i, ranges),
+ search_unigram2(topresults, i, ranges);
+ }
/* no longer pinyin */
if (!(result & SEARCH_CONTINUED))