summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2015-05-28 13:46:07 +0800
committerPeng Wu <alexepico@gmail.com>2015-05-28 13:46:07 +0800
commitcde9cb6b85773069e706ae374396d4b9d2085298 (patch)
tree9e78bb006b77a9ff679832d3f02fcc2f6dfd3a36 /src
parent4e829b1653e347bc171904c0f2c1e487403e3985 (diff)
downloadlibpinyin-cde9cb6b85773069e706ae374396d4b9d2085298.tar.gz
libpinyin-cde9cb6b85773069e706ae374396d4b9d2085298.tar.xz
libpinyin-cde9cb6b85773069e706ae374396d4b9d2085298.zip
update pinyin_guess_full_pinyin_candidates function
Diffstat (limited to 'src')
-rw-r--r--src/pinyin.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/pinyin.cpp b/src/pinyin.cpp
index 0e641a1..5c4c8b3 100644
--- a/src/pinyin.cpp
+++ b/src/pinyin.cpp
@@ -1657,7 +1657,7 @@ bool pinyin_guess_candidates(pinyin_instance_t * instance,
PhraseIndexRanges addon_ranges;
memset(addon_ranges, 0, sizeof(addon_ranges));
- context->m_addon_phrase_index->prepare_ranges(ranges);
+ context->m_addon_phrase_index->prepare_ranges(addon_ranges);
GArray * items = g_array_new(FALSE, FALSE, sizeof(lookup_candidate_t));
@@ -1994,6 +1994,11 @@ bool pinyin_guess_full_pinyin_candidates(pinyin_instance_t * instance,
memset(ranges, 0, sizeof(ranges));
context->m_phrase_index->prepare_ranges(ranges);
+ /* will not handle addon dictionaries in divided or resplit candidate. */
+ PhraseIndexRanges addon_ranges;
+ memset(addon_ranges, 0, sizeof(addon_ranges));
+ context->m_addon_phrase_index->prepare_ranges(addon_ranges);
+
GArray * items = g_array_new(FALSE, FALSE, sizeof(lookup_candidate_t));
if (1 == pinyin_len) {
@@ -2053,6 +2058,9 @@ bool pinyin_guess_full_pinyin_candidates(pinyin_instance_t * instance,
int retval = context->m_pinyin_table->search
(i, keys, ranges);
+ retval = context->m_addon_pinyin_table->search
+ (i, keys, addon_ranges) || retval;
+
found = (retval & SEARCH_OK) || found;
if ( !found )
@@ -2061,6 +2069,10 @@ bool pinyin_guess_full_pinyin_candidates(pinyin_instance_t * instance,
lookup_candidate_t template_item;
_append_items(ranges, &template_item, items);
+ lookup_candidate_t addon_template_item;
+ addon_template_item.m_candidate_type = ADDON_CANDIDATE;
+ _append_items(addon_ranges, &addon_template_item, items);
+
#if 0
g_array_sort(items, compare_item_with_token);