From: Peng Wu Date: Thu, 21 Mar 2013 02:24:12 +0000 (+0800) Subject: update candidates methods X-Git-Tag: 0.9.91~88 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b6f1d7593f57a5e1417def161490373f4603f02e;p=platform%2Fupstream%2Flibpinyin.git update candidates methods --- diff --git a/src/pinyin.cpp b/src/pinyin.cpp index 3894b30..e13a1b4 100644 --- a/src/pinyin.cpp +++ b/src/pinyin.cpp @@ -1221,15 +1221,14 @@ static bool _free_candidates(CandidateVector candidates) { return true; } -bool pinyin_get_candidates(pinyin_instance_t * instance, - size_t offset, - CandidateVector candidates) { +bool pinyin_guess_candidates(pinyin_instance_t * instance, + size_t offset) { pinyin_context_t * & context = instance->m_context; pinyin_option_t & options = context->m_options; ChewingKeyVector & pinyin_keys = instance->m_pinyin_keys; - _free_candidates(candidates); + _free_candidates(instance->m_candidates); size_t pinyin_len = pinyin_keys->len - offset; ssize_t i; @@ -1289,7 +1288,7 @@ bool pinyin_get_candidates(pinyin_instance_t * instance, for (size_t k = 0; k < items->len; ++k) { lookup_candidate_t * item = &g_array_index (items, lookup_candidate_t, k); - g_array_append_val(candidates, *item); + g_array_append_val(instance->m_candidates, *item); } #if 0 @@ -1307,11 +1306,11 @@ bool pinyin_get_candidates(pinyin_instance_t * instance, /* post process to remove duplicated candidates */ - _prepend_sentence_candidate(instance, candidates); + _prepend_sentence_candidate(instance, instance->m_candidates); - _compute_phrase_strings_of_items(instance, offset, candidates); + _compute_phrase_strings_of_items(instance, offset, instance->m_candidates); - _remove_duplicated_items_by_phrase_string(instance, candidates); + _remove_duplicated_items_by_phrase_string(instance, instance->m_candidates); return true; } @@ -1549,15 +1548,14 @@ static bool _try_resplit_table(pinyin_instance_t * instance, return found; } -bool pinyin_get_full_pinyin_candidates(pinyin_instance_t * instance, - size_t offset, - CandidateVector candidates){ +bool pinyin_guess_full_pinyin_candidates(pinyin_instance_t * instance, + size_t offset){ pinyin_context_t * & context = instance->m_context; pinyin_option_t & options = context->m_options; ChewingKeyVector & pinyin_keys = instance->m_pinyin_keys; - _free_candidates(candidates); + _free_candidates(instance->m_candidates); size_t pinyin_len = pinyin_keys->len - offset; pinyin_len = std_lite::min((size_t)MAX_PHRASE_LENGTH, pinyin_len); @@ -1615,7 +1613,7 @@ bool pinyin_get_full_pinyin_candidates(pinyin_instance_t * instance, for (i = 0; i < items->len; ++i) { lookup_candidate_t * item = &g_array_index (items, lookup_candidate_t, i); - g_array_append_val(candidates, *item); + g_array_append_val(instance->m_candidates, *item); } } } @@ -1665,7 +1663,7 @@ bool pinyin_get_full_pinyin_candidates(pinyin_instance_t * instance, for (size_t k = 0; k < items->len; ++k) { lookup_candidate_t * item = &g_array_index (items, lookup_candidate_t, k); - g_array_append_val(candidates, *item); + g_array_append_val(instance->m_candidates, *item); } #if 0 @@ -1683,11 +1681,11 @@ bool pinyin_get_full_pinyin_candidates(pinyin_instance_t * instance, /* post process to remove duplicated candidates */ - _prepend_sentence_candidate(instance, candidates); + _prepend_sentence_candidate(instance, instance->m_candidates); - _compute_phrase_strings_of_items(instance, offset, candidates); + _compute_phrase_strings_of_items(instance, offset, instance->m_candidates); - _remove_duplicated_items_by_phrase_string(instance, candidates); + _remove_duplicated_items_by_phrase_string(instance, instance->m_candidates); return true; }