fixes lookups
authorPeng Wu <alexepico@gmail.com>
Tue, 18 Jun 2013 03:08:48 +0000 (11:08 +0800)
committerPeng Wu <alexepico@gmail.com>
Tue, 18 Jun 2013 03:09:37 +0000 (11:09 +0800)
src/lookup/phrase_lookup.cpp
src/lookup/pinyin_lookup2.cpp

index 114ecb4..f7da0b7 100644 (file)
@@ -106,6 +106,10 @@ PhraseLookup::PhraseLookup(const gfloat lambda,
 
     m_steps_index = g_ptr_array_new();
     m_steps_content = g_ptr_array_new();
+
+    /* the member variables below are saved in get_best_match call. */
+    m_sentence = NULL;
+    m_sentence_length = 0;
 }
 
 PhraseLookup::~PhraseLookup(){
index 8be5c0c..2250a93 100644 (file)
@@ -202,6 +202,10 @@ PinyinLookup2::PinyinLookup2(const gfloat lambda,
 
     m_steps_index = g_ptr_array_new();
     m_steps_content = g_ptr_array_new();
+
+    /* the member variables below are saved in get_best_match call. */
+    m_keys = NULL;
+    m_constraints = NULL;
 }
 
 PinyinLookup2::~PinyinLookup2(){
@@ -594,6 +598,7 @@ bool PinyinLookup2::train_result2(ChewingKeyVector keys,
                 assert(user->set_freq(*token, freq + seed));
                 assert(m_user_bigram->store(last_token, user));
             next:
+                assert(NULL != user);
                 if (user)
                     delete user;
             }