summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2013-04-11 10:57:47 +0800
committerPeng Wu <alexepico@gmail.com>2013-04-11 11:01:24 +0800
commitb72087c4ed9a3d36f6136b74ab848138a0974043 (patch)
tree331f27535b5c64fad4145861fb3ceec47523fefb
parent4f9911da462c0734af9e25a49bb20cdcfea8d4fb (diff)
downloadlibpinyin-b72087c4ed9a3d36f6136b74ab848138a0974043.tar.gz
libpinyin-b72087c4ed9a3d36f6136b74ab848138a0974043.tar.xz
libpinyin-b72087c4ed9a3d36f6136b74ab848138a0974043.zip
update PhraseLookup
-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);