diff options
Diffstat (limited to 'src/lookup')
-rw-r--r-- | src/lookup/phrase_lookup.cpp | 34 | ||||
-rw-r--r-- | src/lookup/phrase_lookup.h | 2 |
2 files changed, 15 insertions, 21 deletions
diff --git a/src/lookup/phrase_lookup.cpp b/src/lookup/phrase_lookup.cpp index 28702c2..fb96fa4 100644 --- a/src/lookup/phrase_lookup.cpp +++ b/src/lookup/phrase_lookup.cpp @@ -147,29 +147,21 @@ bool PhraseLookup::search_bigram(int nstep, phrase_token_t token){ m_system_bigram->load(index_token, system); m_user_bigram->load(index_token, user); - if ( system && user ){ + if ( !merge_single_gram(&m_merged_single_gram, system, user) ) + continue; + + guint32 freq; + if ( m_merged_single_gram.get_freq(token, freq) ){ guint32 total_freq; - assert(user->get_total_freq(total_freq)); - assert(system->set_total_freq(total_freq)); - } - if ( system ){ - guint32 freq; - if ( system->get_freq(token, freq) ){ - guint32 total_freq; - system->get_total_freq(total_freq); - gfloat bigram_poss = freq / (gfloat) total_freq; - found = bigram_gen_next_step(nstep, cur_value, token, bigram_poss) || found; - } - } - if ( user ){ - guint32 freq; - if ( user->get_freq(token, freq) ){ - guint32 total_freq; - user->get_total_freq(total_freq); - gfloat bigram_poss = freq / (gfloat) total_freq; - found = bigram_gen_next_step(nstep, cur_value, token, bigram_poss) || found; - } + m_merged_single_gram.get_total_freq(total_freq); + gfloat bigram_poss = freq / (gfloat) total_freq; + found = bigram_gen_next_step(nstep, cur_value, token, bigram_poss) || found; } + + if (system) + delete system; + if (user) + delete user; } return found; diff --git a/src/lookup/phrase_lookup.h b/src/lookup/phrase_lookup.h index dd1ddc8..a0f0ac2 100644 --- a/src/lookup/phrase_lookup.h +++ b/src/lookup/phrase_lookup.h @@ -23,6 +23,7 @@ #define PHRASE_LOOKUP_H #include "novel_types.h" +#include "ngram.h" #include "lookup.h" /** @file phrase_lookup.h @@ -37,6 +38,7 @@ private: static const gfloat unigram_lambda; PhraseItem m_cache_phrase_item; + SingleGram m_merged_single_gram; protected: //saved varibles FacadePhraseTable * m_phrase_table; |