summaryrefslogtreecommitdiffstats
path: root/src/lookup
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2012-01-10 14:05:43 +0800
committerPeng Wu <alexepico@gmail.com>2012-01-10 15:35:48 +0800
commitf5f55fee7e078375ab40469d0417f202afdbd068 (patch)
tree41452abb960809e5485d7133b00d692f5a7ebcba /src/lookup
parente10ff28e8c84869f1a474b1211d1650300a47b89 (diff)
downloadlibpinyin-f5f55fee7e078375ab40469d0417f202afdbd068.tar.gz
libpinyin-f5f55fee7e078375ab40469d0417f202afdbd068.tar.xz
libpinyin-f5f55fee7e078375ab40469d0417f202afdbd068.zip
let phrase lookup to use merge single gram
Diffstat (limited to 'src/lookup')
-rw-r--r--src/lookup/phrase_lookup.cpp34
-rw-r--r--src/lookup/phrase_lookup.h2
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;