diff options
author | Peng Wu <alexepico@gmail.com> | 2010-11-09 12:50:01 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2010-11-09 12:50:01 +0800 |
commit | b4785a45c0d83fbba1e652b483a42363f3c6cccf (patch) | |
tree | df15da2fd712db7a3ead7714f91f95f30b513978 /src/lookup | |
parent | 33d4a4dba293513531d8b4734b7e1053bc30f1e8 (diff) | |
download | libpinyin-b4785a45c0d83fbba1e652b483a42363f3c6cccf.tar.gz libpinyin-b4785a45c0d83fbba1e652b483a42363f3c6cccf.tar.xz libpinyin-b4785a45c0d83fbba1e652b483a42363f3c6cccf.zip |
fixes a bug in phrase lookup
Diffstat (limited to 'src/lookup')
-rw-r--r-- | src/lookup/phrase_lookup.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/lookup/phrase_lookup.cpp b/src/lookup/phrase_lookup.cpp index e3bf2d9..86c9077 100644 --- a/src/lookup/phrase_lookup.cpp +++ b/src/lookup/phrase_lookup.cpp @@ -104,7 +104,7 @@ bool PhraseLookup::search_unigram(int nstep, phrase_token_t token){ lookup_value_t * max_value = &g_array_index(lookup_content, lookup_value_t, 0); /* find the maximum node */ - for ( size_t i = 1; i < m_steps_content->len; ++i ){ + for ( size_t i = 1; i < lookup_content->len; ++i ){ lookup_value_t * cur_value = &g_array_index(lookup_content, lookup_value_t, i); if ( cur_value->m_poss > max_value->m_poss ) max_value = cur_value; @@ -217,20 +217,20 @@ bool PhraseLookup::save_next_step(int next_step_pos, lookup_value_t * cur_value, bool PhraseLookup::final_step(MatchResults & results ){ //reset results g_array_set_size(results, m_steps_content->len); - for ( size_t i = 0; i < m_steps_content->len; ++i ){ + for ( size_t i = 0; i < results->len; ++i ){ phrase_token_t * token = &g_array_index(results, phrase_token_t, i); *token = null_token; } //find max element size_t last_step_pos = m_steps_content->len - 1; - GArray * last_step_array = (GArray *) g_ptr_array_index(m_steps_content, last_step_pos); - if ( last_step_array->len == 0 ) + GArray * last_step_content = (GArray *) g_ptr_array_index(m_steps_content, last_step_pos); + if ( last_step_content->len == 0 ) return false; - lookup_value_t * max_value = &g_array_index(last_step_array, lookup_value_t, 0); - for ( size_t i = 1; i < last_step_array->len; ++i ){ - lookup_value_t * cur_value = &g_array_index(last_step_array, lookup_value_t, i); + lookup_value_t * max_value = &g_array_index(last_step_content, lookup_value_t, 0); + for ( size_t i = 1; i < last_step_content->len; ++i ){ + lookup_value_t * cur_value = &g_array_index(last_step_content, lookup_value_t, i); if ( cur_value->m_poss > max_value->m_poss ) max_value = cur_value; } |