From 41b5974304689488f006d98155d782880a7e1670 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Wed, 25 May 2016 17:04:49 +0800 Subject: rename m_cache_phrase_item to m_cached_phrase_item --- src/lookup/phrase_lookup.cpp | 12 ++++++------ src/lookup/phrase_lookup.h | 2 +- src/lookup/pinyin_lookup2.cpp | 34 +++++++++++++++++----------------- src/lookup/pinyin_lookup2.h | 2 +- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/lookup/phrase_lookup.cpp b/src/lookup/phrase_lookup.cpp index 6e661ec..ae73a39 100644 --- a/src/lookup/phrase_lookup.cpp +++ b/src/lookup/phrase_lookup.cpp @@ -308,11 +308,11 @@ bool PhraseLookup::search_bigram2(int nstep, PhraseTokens tokens){ bool PhraseLookup::unigram_gen_next_step(int nstep, lookup_value_t * cur_value, phrase_token_t token){ - if (m_phrase_index->get_phrase_item(token, m_cache_phrase_item)) + if (m_phrase_index->get_phrase_item(token, m_cached_phrase_item)) return false; - size_t phrase_length = m_cache_phrase_item.get_phrase_length(); - gdouble elem_poss = m_cache_phrase_item.get_unigram_frequency() / (gdouble) + size_t phrase_length = m_cached_phrase_item.get_phrase_length(); + gdouble elem_poss = m_cached_phrase_item.get_unigram_frequency() / (gdouble) m_phrase_index->get_phrase_index_total_freq(); if ( elem_poss < DBL_EPSILON ) return false; @@ -327,11 +327,11 @@ phrase_token_t token){ bool PhraseLookup::bigram_gen_next_step(int nstep, lookup_value_t * cur_value, phrase_token_t token, gfloat bigram_poss){ - if ( m_phrase_index->get_phrase_item(token, m_cache_phrase_item)) + if ( m_phrase_index->get_phrase_item(token, m_cached_phrase_item)) return false; - size_t phrase_length = m_cache_phrase_item.get_phrase_length(); - gdouble unigram_poss = m_cache_phrase_item.get_unigram_frequency() / + size_t phrase_length = m_cached_phrase_item.get_phrase_length(); + gdouble unigram_poss = m_cached_phrase_item.get_unigram_frequency() / (gdouble) m_phrase_index->get_phrase_index_total_freq(); if ( bigram_poss < FLT_EPSILON && unigram_poss < DBL_EPSILON ) diff --git a/src/lookup/phrase_lookup.h b/src/lookup/phrase_lookup.h index 341b7bc..6f3dd85 100644 --- a/src/lookup/phrase_lookup.h +++ b/src/lookup/phrase_lookup.h @@ -46,7 +46,7 @@ private: const gfloat bigram_lambda; const gfloat unigram_lambda; - PhraseItem m_cache_phrase_item; + PhraseItem m_cached_phrase_item; SingleGram m_merged_single_gram; protected: //saved varibles diff --git a/src/lookup/pinyin_lookup2.cpp b/src/lookup/pinyin_lookup2.cpp index 7162a67..1c1ec23 100644 --- a/src/lookup/pinyin_lookup2.cpp +++ b/src/lookup/pinyin_lookup2.cpp @@ -396,17 +396,17 @@ bool PinyinLookup2::unigram_gen_next_step(int start, int end, lookup_value_t * cur_step, phrase_token_t token) { - if (m_phrase_index->get_phrase_item(token, m_cache_phrase_item)) + if (m_phrase_index->get_phrase_item(token, m_cached_phrase_item)) return false; - size_t phrase_length = m_cache_phrase_item.get_phrase_length(); - gdouble elem_poss = m_cache_phrase_item.get_unigram_frequency() / (gdouble) + size_t phrase_length = m_cached_phrase_item.get_phrase_length(); + gdouble elem_poss = m_cached_phrase_item.get_unigram_frequency() / (gdouble) m_phrase_index->get_phrase_index_total_freq(); if ( elem_poss < DBL_EPSILON ) return false; gfloat pinyin_poss = compute_pronunciation_possibility - (m_options, m_matrix, start, end, m_cached_keys, m_cache_phrase_item); + (m_options, m_matrix, start, end, m_cached_keys, m_cached_phrase_item); if (pinyin_poss < FLT_EPSILON ) return false; @@ -424,17 +424,17 @@ bool PinyinLookup2::bigram_gen_next_step(int start, int end, phrase_token_t token, gfloat bigram_poss) { - if (m_phrase_index->get_phrase_item(token, m_cache_phrase_item)) + if (m_phrase_index->get_phrase_item(token, m_cached_phrase_item)) return false; - size_t phrase_length = m_cache_phrase_item.get_phrase_length(); - gdouble unigram_poss = m_cache_phrase_item.get_unigram_frequency() / + size_t phrase_length = m_cached_phrase_item.get_phrase_length(); + gdouble unigram_poss = m_cached_phrase_item.get_unigram_frequency() / (gdouble) m_phrase_index->get_phrase_index_total_freq(); if ( bigram_poss < FLT_EPSILON && unigram_poss < DBL_EPSILON ) return false; gfloat pinyin_poss = compute_pronunciation_possibility - (m_options, m_matrix, start, end, m_cached_keys, m_cache_phrase_item); + (m_options, m_matrix, start, end, m_cached_keys, m_cached_phrase_item); if ( pinyin_poss < FLT_EPSILON ) return false; @@ -610,8 +610,8 @@ bool PinyinLookup2::train_result2(ChewingKeyVector keys, } /* train uni-gram */ - m_phrase_index->get_phrase_item(*token, m_cache_phrase_item); - m_cache_phrase_item.increase_pronunciation_possibility + m_phrase_index->get_phrase_item(*token, m_cached_phrase_item); + m_cached_phrase_item.increase_pronunciation_possibility (m_options, pinyin_keys + i, seed * pinyin_factor); m_phrase_index->add_unigram_frequency (*token, seed * unigram_factor); @@ -626,10 +626,10 @@ int PinyinLookup2::add_constraint(CandidateConstraints constraints, size_t index, phrase_token_t token) { - if (m_phrase_index->get_phrase_item(token, m_cache_phrase_item)) + if (m_phrase_index->get_phrase_item(token, m_cached_phrase_item)) return 0; - size_t phrase_length = m_cache_phrase_item.get_phrase_length(); + size_t phrase_length = m_cached_phrase_item.get_phrase_length(); if ( index + phrase_length > constraints->len ) return 0; @@ -673,10 +673,10 @@ bool PinyinLookup2::clear_constraint(CandidateConstraints constraints, assert(constraint->m_type == CONSTRAINT_ONESTEP); phrase_token_t token = constraint->m_token; - if (m_phrase_index->get_phrase_item(token, m_cache_phrase_item)) + if (m_phrase_index->get_phrase_item(token, m_cached_phrase_item)) return false; - size_t phrase_length = m_cache_phrase_item.get_phrase_length(); + size_t phrase_length = m_cached_phrase_item.get_phrase_length(); for ( size_t i = 0; i < phrase_length; ++i){ if (index + i >= constraints->len) continue; @@ -716,8 +716,8 @@ bool PinyinLookup2::validate_constraint(CandidateConstraints constraints, if ( constraint->m_type == CONSTRAINT_ONESTEP ){ phrase_token_t token = constraint->m_token; - m_phrase_index->get_phrase_item(token, m_cache_phrase_item); - size_t phrase_length = m_cache_phrase_item.get_phrase_length(); + m_phrase_index->get_phrase_item(token, m_cached_phrase_item); + size_t phrase_length = m_cached_phrase_item.get_phrase_length(); /* clear too long constraint */ if (i + phrase_length > constraints->len){ @@ -727,7 +727,7 @@ bool PinyinLookup2::validate_constraint(CandidateConstraints constraints, ChewingKey * pinyin_keys = (ChewingKey *)keys->data; /* clear invalid pinyin */ - gfloat pinyin_poss = m_cache_phrase_item.get_pronunciation_possibility(m_options, pinyin_keys + i); + gfloat pinyin_poss = m_cached_phrase_item.get_pronunciation_possibility(m_options, pinyin_keys + i); if (pinyin_poss < FLT_EPSILON) clear_constraint(constraints, i); } diff --git a/src/lookup/pinyin_lookup2.h b/src/lookup/pinyin_lookup2.h index 6a7f14f..fa7dee0 100644 --- a/src/lookup/pinyin_lookup2.h +++ b/src/lookup/pinyin_lookup2.h @@ -88,7 +88,7 @@ private: const gfloat unigram_lambda; GArray * m_cached_keys; - PhraseItem m_cache_phrase_item; + PhraseItem m_cached_phrase_item; SingleGram m_merged_single_gram; protected: -- cgit