diff options
author | Peng Wu <alexepico@gmail.com> | 2011-10-11 11:03:10 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2011-10-11 11:03:10 +0800 |
commit | 84b8ecaf7b1c016b304015788e5ded68abc0d7db (patch) | |
tree | c3e74a9428ddadd2810c6384c8c1d73ba8f18b9a /src/lookup | |
parent | e478deb3365e6b46bfde473ff0c09d47ac89cc45 (diff) | |
download | libpinyin-84b8ecaf7b1c016b304015788e5ded68abc0d7db.tar.gz libpinyin-84b8ecaf7b1c016b304015788e5ded68abc0d7db.tar.xz libpinyin-84b8ecaf7b1c016b304015788e5ded68abc0d7db.zip |
re-factor choose candidate
Diffstat (limited to 'src/lookup')
-rw-r--r-- | src/lookup/pinyin_lookup.cpp | 8 | ||||
-rw-r--r-- | src/lookup/pinyin_lookup.h | 2 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/lookup/pinyin_lookup.cpp b/src/lookup/pinyin_lookup.cpp index 4e67c49..2e6408d 100644 --- a/src/lookup/pinyin_lookup.cpp +++ b/src/lookup/pinyin_lookup.cpp @@ -494,13 +494,13 @@ bool PinyinLookup::train_result(PinyinKeyVector keys, CandidateConstraints const return true; } -bool PinyinLookup::add_constraint(CandidateConstraints constraints, size_t index, phrase_token_t token){ +guint8 PinyinLookup::add_constraint(CandidateConstraints constraints, size_t index, phrase_token_t token){ if ( m_phrase_index->get_phrase_item(token, m_cache_phrase_item) ) - return false; + return 0; size_t phrase_length = m_cache_phrase_item.get_phrase_length(); if ( index + phrase_length > constraints->len ) - return false; + return 0; for ( size_t i = index; i < index + phrase_length ; ++i ){ clear_constraint(constraints, i); @@ -515,7 +515,7 @@ bool PinyinLookup::add_constraint(CandidateConstraints constraints, size_t index constraint->m_type = CONSTRAINT_NOSEARCH; constraint->m_constraint_step = index; } - return true; + return phrase_length; } bool PinyinLookup::clear_constraint(CandidateConstraints constraints, size_t index){ diff --git a/src/lookup/pinyin_lookup.h b/src/lookup/pinyin_lookup.h index 47cc4a9..7bc206d 100644 --- a/src/lookup/pinyin_lookup.h +++ b/src/lookup/pinyin_lookup.h @@ -134,7 +134,7 @@ public: } /* user interactions */ - bool add_constraint(CandidateConstraints constraints, size_t index, phrase_token_t token); + guint8 add_constraint(CandidateConstraints constraints, size_t index, phrase_token_t token); bool clear_constraint(CandidateConstraints constraints, size_t index); |