update PhraseLookup
authorPeng Wu <alexepico@gmail.com>
Thu, 11 Apr 2013 02:57:47 +0000 (10:57 +0800)
committerPeng Wu <alexepico@gmail.com>
Thu, 11 Apr 2013 03:01:24 +0000 (11:01 +0800)
src/lookup/phrase_lookup.cpp
src/lookup/phrase_lookup.h

index 3cfdd3a..114ecb4 100644 (file)
 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;
index 3d3948c..cf65692 100644 (file)
@@ -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);