From b72087c4ed9a3d36f6136b74ab848138a0974043 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Thu, 11 Apr 2013 10:57:47 +0800 Subject: update PhraseLookup --- src/lookup/phrase_lookup.cpp | 15 ++++++++++----- src/lookup/phrase_lookup.h | 8 +++++--- 2 files changed, 15 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/lookup/phrase_lookup.cpp b/src/lookup/phrase_lookup.cpp index 3cfdd3a..114ecb4 100644 --- a/src/lookup/phrase_lookup.cpp +++ b/src/lookup/phrase_lookup.cpp @@ -30,9 +30,10 @@ using namespace pinyin; -const gfloat PhraseLookup::bigram_lambda = LAMBDA_PARAMETER; -const gfloat PhraseLookup::unigram_lambda = 1 - LAMBDA_PARAMETER; - +/* +const gfloat PhraseLookup::bigram_lambda = lambda; +const gfloat PhraseLookup::unigram_lambda = 1 - lambda; +*/ static bool populate_prefixes(GPtrArray * steps_index, GPtrArray * steps_content) { @@ -90,10 +91,14 @@ static void clear_steps(GPtrArray * steps_index, } } -PhraseLookup::PhraseLookup(FacadePhraseTable2 * phrase_table, +PhraseLookup::PhraseLookup(const gfloat lambda, + FacadePhraseTable2 * phrase_table, FacadePhraseIndex * phrase_index, Bigram * system_bigram, - Bigram * user_bigram){ + Bigram * user_bigram) + : bigram_lambda(lambda), + unigram_lambda(1. - lambda) +{ m_phrase_table = phrase_table; m_phrase_index = phrase_index; m_system_bigram = system_bigram; diff --git a/src/lookup/phrase_lookup.h b/src/lookup/phrase_lookup.h index 3d3948c..cf65692 100644 --- a/src/lookup/phrase_lookup.h +++ b/src/lookup/phrase_lookup.h @@ -43,8 +43,8 @@ namespace pinyin{ */ class PhraseLookup{ private: - static const gfloat bigram_lambda; - static const gfloat unigram_lambda; + const gfloat bigram_lambda; + const gfloat unigram_lambda; PhraseItem m_cache_phrase_item; SingleGram m_merged_single_gram; @@ -81,6 +81,7 @@ protected: public: /** * PhraseLookup::PhraseLookup: + * @lambda: the lambda parameter for interpolation model. * @phrase_table: the phrase table. * @phrase_index: the phrase index. * @system_bigram: the system bi-gram. @@ -89,7 +90,8 @@ public: * The constructor of the PhraseLookup. * */ - PhraseLookup(FacadePhraseTable2 * phrase_table, + PhraseLookup(const gfloat lambda, + FacadePhraseTable2 * phrase_table, FacadePhraseIndex * phrase_index, Bigram * system_bigram, Bigram * user_bigram); -- cgit