diff options
Diffstat (limited to 'src/lookup')
-rw-r--r-- | src/lookup/lookup.cpp | 6 | ||||
-rw-r--r-- | src/lookup/lookup.h | 2 | ||||
-rw-r--r-- | src/lookup/phonetic_lookup.cpp | 4 | ||||
-rw-r--r-- | src/lookup/phonetic_lookup.h | 20 | ||||
-rw-r--r-- | src/lookup/phrase_lookup.cpp | 14 | ||||
-rw-r--r-- | src/lookup/phrase_lookup.h | 8 | ||||
-rw-r--r-- | src/lookup/pinyin_lookup2.cpp | 22 | ||||
-rw-r--r-- | src/lookup/pinyin_lookup2.h | 16 |
8 files changed, 46 insertions, 46 deletions
diff --git a/src/lookup/lookup.cpp b/src/lookup/lookup.cpp index e5bae85..ac3d705 100644 --- a/src/lookup/lookup.cpp +++ b/src/lookup/lookup.cpp @@ -25,7 +25,7 @@ namespace pinyin{ bool convert_to_utf8(FacadePhraseIndex * phrase_index, - MatchResults match_results, + MatchResult result, /* in */ const char * delimiter, /* in */ bool show_tokens, /* out */ char * & result_string){ @@ -36,9 +36,9 @@ bool convert_to_utf8(FacadePhraseIndex * phrase_index, PhraseItem item; - for ( size_t i = 0; i < match_results->len; ++i ){ + for ( size_t i = 0; i < result->len; ++i ){ phrase_token_t token = g_array_index - (match_results, phrase_token_t, i); + (result, phrase_token_t, i); if ( null_token == token ) continue; diff --git a/src/lookup/lookup.h b/src/lookup/lookup.h index 27a426a..47fe204 100644 --- a/src/lookup/lookup.h +++ b/src/lookup/lookup.h @@ -73,7 +73,7 @@ typedef GHashTable * LookupStepIndex; typedef GArray * LookupStepContent; /* array of lookup_value_t */ bool convert_to_utf8(FacadePhraseIndex * phrase_index, - MatchResults match_results, + MatchResult match_result, /* in */ const char * delimiter, /* in */ bool show_tokens, /* out */ char * & result_string); diff --git a/src/lookup/phonetic_lookup.cpp b/src/lookup/phonetic_lookup.cpp index 5c3a6ce..417ee9f 100644 --- a/src/lookup/phonetic_lookup.cpp +++ b/src/lookup/phonetic_lookup.cpp @@ -172,8 +172,8 @@ bool ForwardPhoneticConstraints::validate_constraint(PhoneticKeyMatrix * matrix) } -bool ForwardPhoneticConstraints::diff_result(MatchResults best, - MatchResults other){ +bool ForwardPhoneticConstraints::diff_result(MatchResult best, + MatchResult other){ bool changed = false; assert(best->len == other->len); diff --git a/src/lookup/phonetic_lookup.h b/src/lookup/phonetic_lookup.h index f1fdae0..9a147ed 100644 --- a/src/lookup/phonetic_lookup.h +++ b/src/lookup/phonetic_lookup.h @@ -366,7 +366,7 @@ public: template <gint32 nbest> bool extract_result(const ForwardPhoneticTrellis<nbest> * trellis, const trellis_value_t * tail, - /* out */ MatchResults & result) { + /* out */ MatchResult & result) { /* reset result */ g_array_set_size(result, trellis->size()); for (size_t i = 0; i < result->len; ++i){ @@ -445,7 +445,7 @@ public: return true; } - bool diff_result(MatchResults best, MatchResults other); + bool diff_result(MatchResult best, MatchResult other); }; @@ -469,19 +469,19 @@ public: return m_results->len; } - bool get_result(size_t index, MatchResults & result) const { + bool get_result(size_t index, MatchResult & result) const { if (index >= m_results->len) return false; - result = (MatchResults) g_ptr_array_index(m_results, index); + result = (MatchResult) g_ptr_array_index(m_results, index); return true; } bool clear() { /* free m_results */ for (size_t i = 0; i < m_results->len; ++i) { - MatchResults array = - (MatchResults) g_ptr_array_index(m_results, i); + MatchResult array = + (MatchResult) g_ptr_array_index(m_results, i); g_array_free(array, TRUE); } g_ptr_array_set_size(m_results, 0); @@ -490,8 +490,8 @@ public: } /* copy result here */ - bool add_result(MatchResults result) { - MatchResults array = g_array_new + bool add_result(MatchResult result) { + MatchResult array = g_array_new (TRUE, TRUE, sizeof(phrase_token_t)); g_array_append_vals(array, result->data, result->len); @@ -812,7 +812,7 @@ public: GPtrArray * tails = g_ptr_array_new(); m_trellis.get_tails(tails); - MatchResults result = g_array_new + MatchResult result = g_array_new (TRUE, TRUE, sizeof(phrase_token_t)); for (size_t i = 0; i < tails->len; ++i) { const trellis_value_t * tail = (const trellis_value_t *) @@ -830,7 +830,7 @@ public: bool train_result3(const PhoneticKeyMatrix * matrix, const ForwardPhoneticConstraints * constraints, - MatchResults result) { + MatchResult result) { const guint32 initial_seed = 23 * 3; const guint32 expand_factor = 2; const guint32 unigram_factor = 7; diff --git a/src/lookup/phrase_lookup.cpp b/src/lookup/phrase_lookup.cpp index 662d788..d42e069 100644 --- a/src/lookup/phrase_lookup.cpp +++ b/src/lookup/phrase_lookup.cpp @@ -117,7 +117,7 @@ PhraseLookup::~PhraseLookup(){ } bool PhraseLookup::get_best_match(int sentence_length, ucs4_t sentence[], - MatchResults & results){ + MatchResult & result){ m_sentence_length = sentence_length; m_sentence = sentence; int nstep = m_sentence_length + 1; @@ -154,7 +154,7 @@ bool PhraseLookup::get_best_match(int sentence_length, ucs4_t sentence[], m_phrase_index->destroy_tokens(tokens); - return final_step(results); + return final_step(result); } #if 0 @@ -379,12 +379,12 @@ bool PhraseLookup::save_next_step(int next_step_pos, lookup_value_t * cur_value, } } -bool PhraseLookup::final_step(MatchResults & results ){ +bool PhraseLookup::final_step(MatchResult & result){ /* reset results */ - g_array_set_size(results, m_steps_content->len - 1); - for ( size_t i = 0; i < results->len; ++i ){ - phrase_token_t * token = &g_array_index(results, phrase_token_t, i); + g_array_set_size(result, m_steps_content->len - 1); + for ( size_t i = 0; i < result->len; ++i ){ + phrase_token_t * token = &g_array_index(result, phrase_token_t, i); *token = null_token; } @@ -411,7 +411,7 @@ bool PhraseLookup::final_step(MatchResults & results ){ break; phrase_token_t * token = &g_array_index - (results, phrase_token_t, cur_step_pos); + (result, phrase_token_t, cur_step_pos); *token = max_value->m_handles[1]; phrase_token_t last_token = max_value->m_handles[0]; diff --git a/src/lookup/phrase_lookup.h b/src/lookup/phrase_lookup.h index b744854..df6a55d 100644 --- a/src/lookup/phrase_lookup.h +++ b/src/lookup/phrase_lookup.h @@ -76,7 +76,7 @@ protected: bool save_next_step(int next_step_pos, lookup_value_t * cur_value, lookup_value_t * next_step); - bool final_step(MatchResults & results); + bool final_step(MatchResult & result); public: /** * PhraseLookup::PhraseLookup: @@ -115,7 +115,7 @@ public: * Note: this method only accepts the characters in phrase large table. * */ - bool get_best_match(int sentence_length, ucs4_t sentence[], MatchResults & results); + bool get_best_match(int sentence_length, ucs4_t sentence[], MatchResult & result); /** * PhraseLookup::convert_to_utf8: @@ -128,10 +128,10 @@ public: * Note: free the result_string by g_free. * */ - bool convert_to_utf8(MatchResults results, + bool convert_to_utf8(MatchResult result, /* out */ char * & result_string) { - return pinyin::convert_to_utf8(m_phrase_index, results, + return pinyin::convert_to_utf8(m_phrase_index, result, "\n", true, result_string); } }; diff --git a/src/lookup/pinyin_lookup2.cpp b/src/lookup/pinyin_lookup2.cpp index c72bc86..bb3d053 100644 --- a/src/lookup/pinyin_lookup2.cpp +++ b/src/lookup/pinyin_lookup2.cpp @@ -218,7 +218,7 @@ PinyinLookup2::~PinyinLookup2(){ bool PinyinLookup2::get_best_match(TokenVector prefixes, PhoneticKeyMatrix * matrix, CandidateConstraints constraints, - MatchResults & results){ + MatchResult & result){ m_constraints = constraints; m_matrix = matrix; @@ -304,7 +304,7 @@ bool PinyinLookup2::get_best_match(TokenVector prefixes, g_ptr_array_free(candidates, TRUE); g_ptr_array_free(topresults, TRUE); - return final_step(results); + return final_step(result); } bool PinyinLookup2::search_unigram2(GPtrArray * topresults, @@ -507,12 +507,12 @@ bool PinyinLookup2::save_next_step(int next_step_pos, } } -bool PinyinLookup2::final_step(MatchResults & results){ +bool PinyinLookup2::final_step(MatchResult & result){ - /* reset results */ - g_array_set_size(results, m_steps_content->len); - for (size_t i = 0; i < results->len; ++i){ - phrase_token_t * token = &g_array_index(results, phrase_token_t, i); + /* reset result */ + g_array_set_size(result, m_steps_content->len); + for (size_t i = 0; i < result->len; ++i){ + phrase_token_t * token = &g_array_index(result, phrase_token_t, i); *token = null_token; } @@ -539,7 +539,7 @@ bool PinyinLookup2::final_step(MatchResults & results){ break; phrase_token_t * token = &g_array_index - (results, phrase_token_t, cur_step_pos); + (result, phrase_token_t, cur_step_pos); *token = max_value->m_handles[1]; phrase_token_t last_token = max_value->m_handles[0]; @@ -565,7 +565,7 @@ bool PinyinLookup2::final_step(MatchResults & results){ bool PinyinLookup2::train_result2(PhoneticKeyMatrix * matrix, CandidateConstraints constraints, - MatchResults results) { + MatchResult result) { const guint32 initial_seed = 23 * 3; const guint32 expand_factor = 2; const guint32 unigram_factor = 7; @@ -578,7 +578,7 @@ bool PinyinLookup2::train_result2(PhoneticKeyMatrix * matrix, phrase_token_t last_token = sentence_start; for (size_t i = 0; i < constraints->len; ++i) { - phrase_token_t token = g_array_index(results, phrase_token_t, i); + phrase_token_t token = g_array_index(result, phrase_token_t, i); if (null_token == token) continue; @@ -633,7 +633,7 @@ bool PinyinLookup2::train_result2(PhoneticKeyMatrix * matrix, guint next_pos = i + 1; for (; next_pos < constraints->len; ++next_pos) { phrase_token_t next_token = g_array_index - (results, phrase_token_t, next_pos); + (result, phrase_token_t, next_pos); if (null_token != next_token) break; diff --git a/src/lookup/pinyin_lookup2.h b/src/lookup/pinyin_lookup2.h index bd3d774..7a21966 100644 --- a/src/lookup/pinyin_lookup2.h +++ b/src/lookup/pinyin_lookup2.h @@ -125,7 +125,7 @@ protected: bool save_next_step(int next_step_pos, lookup_value_t * cur_step, lookup_value_t * next_step); - bool final_step(MatchResults & results); + bool final_step(MatchResult & result); public: /** @@ -158,7 +158,7 @@ public: * @prefixes: the phrase tokens before the guessed sentence. * @matrix: the matrix of the pinyin keys. * @constraints: the constraints on the guessed sentence. - * @results: the guessed sentence in the form of the phrase tokens. + * @result: the guessed sentence in the form of the phrase tokens. * @returns: whether the guess operation is successful. * * Guess the best sentence according to user inputs. @@ -167,13 +167,13 @@ public: bool get_best_match(TokenVector prefixes, PhoneticKeyMatrix * matrix, CandidateConstraints constraints, - MatchResults & results); + MatchResult & result); /** * PinyinLookup2::train_result2: * @matrix: the matrix of the pinyin keys. * @constraints: the constraints on the guessed sentence. - * @results: the guessed sentence in the form of the phrase tokens. + * @result: the guessed sentence in the form of the phrase tokens. * @returns: whether the train operation is successful. * * Self learning the guessed sentence based on the constraints. @@ -181,21 +181,21 @@ public: */ bool train_result2(PhoneticKeyMatrix * matrix, CandidateConstraints constraints, - MatchResults results); + MatchResult result); /** * PinyinLookup2::convert_to_utf8: - * @results: the guessed sentence in the form of the phrase tokens. + * @result: the guessed sentence in the form of the phrase tokens. * @result_string: the guessed sentence in the utf8 encoding. * @returns: whether the convert operation is successful. * * Convert the guessed sentence from the phrase tokens to the utf8 string. * */ - bool convert_to_utf8(MatchResults results, + bool convert_to_utf8(MatchResult result, /* out */ char * & result_string) { - return pinyin::convert_to_utf8(m_phrase_index, results, + return pinyin::convert_to_utf8(m_phrase_index, result, NULL, false, result_string); } |