From 669090ae1dfca2fa3ac1cbd1612648891b53353f Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Thu, 11 Apr 2013 11:04:25 +0800 Subject: update PinyinLookup2 --- src/lookup/pinyin_lookup2.cpp | 15 ++++++++++----- src/lookup/pinyin_lookup2.h | 12 ++++++++---- 2 files changed, 18 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/lookup/pinyin_lookup2.cpp b/src/lookup/pinyin_lookup2.cpp index f4ec3ac..8be5c0c 100644 --- a/src/lookup/pinyin_lookup2.cpp +++ b/src/lookup/pinyin_lookup2.cpp @@ -26,9 +26,10 @@ using namespace pinyin; -const gfloat PinyinLookup2::bigram_lambda = LAMBDA_PARAMETER; -const gfloat PinyinLookup2::unigram_lambda = 1 - LAMBDA_PARAMETER; - +/* +const gfloat PinyinLookup2::bigram_lambda = lambda; +const gfloat PinyinLookup2::unigram_lambda = 1 - lambda; +*/ /* internal definition */ static const size_t nbeam = 32; @@ -184,11 +185,15 @@ static void clear_steps(GPtrArray * steps_index, GPtrArray * steps_content){ } -PinyinLookup2::PinyinLookup2(pinyin_option_t options, +PinyinLookup2::PinyinLookup2(const gfloat lambda, + pinyin_option_t options, FacadeChewingTable * pinyin_table, FacadePhraseIndex * phrase_index, Bigram * system_bigram, - Bigram * user_bigram){ + Bigram * user_bigram) + : bigram_lambda(lambda), + unigram_lambda(1. - lambda) +{ m_options = options; m_pinyin_table = pinyin_table; m_phrase_index = phrase_index; diff --git a/src/lookup/pinyin_lookup2.h b/src/lookup/pinyin_lookup2.h index 1509d65..dbe15c9 100644 --- a/src/lookup/pinyin_lookup2.h +++ b/src/lookup/pinyin_lookup2.h @@ -80,8 +80,8 @@ struct lookup_constraint_t{ */ class PinyinLookup2{ 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; @@ -119,6 +119,7 @@ protected: public: /** * PinyinLookup2::PinyinLookup2: + * @lambda: the lambda parameter for interpolation model. * @options: the pinyin options. * @pinyin_table: the pinyin table. * @phrase_index: the phrase index. @@ -128,8 +129,11 @@ public: * The constructor of the PinyinLookup2. * */ - PinyinLookup2(pinyin_option_t options, FacadeChewingTable * pinyin_table, - FacadePhraseIndex * phrase_index, Bigram * system_bigram, + PinyinLookup2(const gfloat lambda, + pinyin_option_t options, + FacadeChewingTable * pinyin_table, + FacadePhraseIndex * phrase_index, + Bigram * system_bigram, Bigram * user_bigram); /** -- cgit