fixes pinyin lookup
authorPeng Wu <alexepico@gmail.com>
Mon, 16 Aug 2010 07:21:19 +0000 (15:21 +0800)
committerPeng Wu <alexepico@gmail.com>
Mon, 16 Aug 2010 07:21:19 +0000 (15:21 +0800)
src/lookup/pinyin_lookup.cpp
src/training/estimate_interpolation.cpp

index 5beab26..0b5cf4d 100644 (file)
@@ -309,7 +309,7 @@ bool PinyinLookup::search_bigram(IBranchIterator * iter,
 
 bool PinyinLookup::unigram_gen_next_step(int nstep, lookup_value_t * cur_step, phrase_token_t token){
     PinyinKey * pinyinkeys = ((PinyinKey *)m_keys->data) + nstep;
-    if (!m_phrase_index->get_phrase_item(token, m_cache_phrase_item))
+    if (m_phrase_index->get_phrase_item(token, m_cache_phrase_item))
        return false;
     size_t phrase_length = m_cache_phrase_item.get_phrase_length();
     gfloat elem_poss = m_cache_phrase_item.get_unigram_frequency() / (gfloat)
@@ -329,7 +329,7 @@ bool PinyinLookup::unigram_gen_next_step(int nstep, lookup_value_t * cur_step, p
 
 bool PinyinLookup::bigram_gen_next_step(int nstep, lookup_value_t * cur_step, phrase_token_t token, gfloat bigram_poss){
     PinyinKey * pinyinkeys = ((PinyinKey *)m_keys->data) + nstep;
-    if (!m_phrase_index->get_phrase_item(token, m_cache_phrase_item))
+    if (m_phrase_index->get_phrase_item(token, m_cache_phrase_item))
        return false;
     size_t phrase_length = m_cache_phrase_item.get_phrase_length();
     gfloat unigram_poss = m_cache_phrase_item.get_unigram_frequency() / (gfloat)
@@ -498,7 +498,7 @@ bool PinyinLookup::convert_to_utf8(MatchResults results, /* out */ char * & resu
 }
 
 bool PinyinLookup::add_constraint(CandidateConstraints constraints, size_t index, phrase_token_t token){
-    if ( !m_phrase_index->get_phrase_item(token, m_cache_phrase_item) )
+    if ( m_phrase_index->get_phrase_item(token, m_cache_phrase_item) )
        return false;
 
     size_t phrase_length = m_cache_phrase_item.get_phrase_length();
@@ -535,7 +535,7 @@ bool PinyinLookup::clear_constraint(CandidateConstraints constraints, size_t ind
     assert(constraint->m_type == CONSTRAINT_ONESTEP);    
 
     phrase_token_t token = constraint->m_token;
-    if (!m_phrase_index->get_phrase_item(token, m_cache_phrase_item))
+    if (m_phrase_index->get_phrase_item(token, m_cache_phrase_item))
        return false;
 
     size_t phrase_length = m_cache_phrase_item.get_phrase_length();
index 5aa9ea5..afe369e 100644 (file)
@@ -73,7 +73,7 @@ parameter_t compute_interpolation(SingleGram * deleted_bigram,
                guint32 freq = 0;
                parameter_t elem_poss = 0;
                PhraseItem item;
-               if (unigram->get_phrase_item(token, item)){
+               if (!unigram->get_phrase_item(token, item)){
                    guint32 freq = item.get_unigram_frequency();
                    guint32 total_freq = unigram->get_phrase_index_total_freq();
                    elem_poss = freq / (parameter_t)total_freq;