summaryrefslogtreecommitdiffstats
path: root/src/lookup
diff options
context:
space:
mode:
Diffstat (limited to 'src/lookup')
-rw-r--r--src/lookup/phrase_lookup.cpp15
-rw-r--r--src/lookup/phrase_lookup.h8
2 files changed, 15 insertions, 8 deletions
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);