diff options
author | Peng Wu <alexepico@gmail.com> | 2012-10-19 15:16:10 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2012-10-19 15:16:10 +0800 |
commit | 1256e3c800f7d9136bcaf33627971b27e598bb83 (patch) | |
tree | b1cd9deebe7836dcd65761194df6531b4c2e6853 /src/pinyin.cpp | |
parent | 1a663eac6e9dcd16375690d9ab54f51bf02c83b7 (diff) | |
download | libpinyin-1256e3c800f7d9136bcaf33627971b27e598bb83.tar.gz libpinyin-1256e3c800f7d9136bcaf33627971b27e598bb83.tar.xz libpinyin-1256e3c800f7d9136bcaf33627971b27e598bb83.zip |
update pinyin_guess_sentence_with_prefix
Diffstat (limited to 'src/pinyin.cpp')
-rw-r--r-- | src/pinyin.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/pinyin.cpp b/src/pinyin.cpp index b291c57..d032f6d 100644 --- a/src/pinyin.cpp +++ b/src/pinyin.cpp @@ -625,6 +625,7 @@ bool pinyin_guess_sentence_with_prefix(pinyin_instance_t * instance, glong len_str = 0; ucs4_t * ucs4_str = g_utf8_to_ucs4(prefix, -1, NULL, &len_str, NULL); + GArray * tokenarray = g_array_new(FALSE, FALSE, sizeof(phrase_token_t)); if (ucs4_str && len_str) { /* add prefixes. */ @@ -639,12 +640,15 @@ bool pinyin_guess_sentence_with_prefix(pinyin_instance_t * instance, memset(tokens, 0, sizeof(tokens)); phrase_index->prepare_tokens(tokens); int result = context->m_phrase_table->search(i, start, tokens); - int num = get_first_token(tokens, token); + int num = reduce_tokens(tokens, tokenarray); phrase_index->destroy_tokens(tokens); + if (result & SEARCH_OK) - g_array_append_val(instance->m_prefixes, token); + g_array_append_vals(instance->m_prefixes, + tokenarray->data, tokenarray->len); } } + g_array_free(tokenarray, TRUE); g_free(ucs4_str); pinyin_update_constraints(instance); |