summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2017-01-21 10:40:41 +0800
committerPeng Wu <alexepico@gmail.com>2017-01-21 10:40:41 +0800
commit70d3d40b972b8b582782d72c05ce2b2d3fcac82c (patch)
treee951540da01c11283b48265f25f308eeafadf166
parentccf418653381d6a7973612b88515e63032950a0f (diff)
downloadlibpinyin-70d3d40b972b8b582782d72c05ce2b2d3fcac82c.tar.gz
libpinyin-70d3d40b972b8b582782d72c05ce2b2d3fcac82c.tar.xz
libpinyin-70d3d40b972b8b582782d72c05ce2b2d3fcac82c.zip
fixes trellis_value_less_than function
-rw-r--r--src/lookup/phonetic_lookup.h21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/lookup/phonetic_lookup.h b/src/lookup/phonetic_lookup.h
index c54f483..f6b0514 100644
--- a/src/lookup/phonetic_lookup.h
+++ b/src/lookup/phonetic_lookup.h
@@ -64,22 +64,21 @@ static bool inline trellis_value_less_than(const trellis_value_t * exist_item,
if (exist_item->m_sentence_length + 1 == new_item->m_sentence_length &&
exist_item->m_poss + LONG_SENTENCE_PENALTY < new_item->m_poss)
return true;
- }
-
- /* shorter sentence */
- if (exist_item->m_sentence_length > new_item->m_sentence_length ||
- /* the same length but better possibility */
- (exist_item->m_sentence_length == new_item->m_sentence_length &&
- exist_item->m_poss < new_item->m_poss))
- return true;
- if (nbest > 1) {
- /* allow longer sentence */
if (exist_item->m_sentence_length == new_item->m_sentence_length + 1 &&
exist_item->m_poss < new_item->m_poss + LONG_SENTENCE_PENALTY)
return true;
}
+ /* the same length but better possibility */
+ if (exist_item->m_sentence_length == new_item->m_sentence_length &&
+ exist_item->m_poss < new_item->m_poss)
+ return true;
+
+ /* shorter sentence */
+ if (exist_item->m_sentence_length > new_item->m_sentence_length)
+ return true;
+
return false;
}
@@ -625,7 +624,7 @@ protected:
bool save_next_step(int index, trellis_value_t * candidate) {
lookup_key_t token = candidate->m_handles[1];
- m_trellis.insert_candidate(index, token, candidate);
+ return m_trellis.insert_candidate(index, token, candidate);
}
public: