diff options
author | Peng Wu <alexepico@gmail.com> | 2011-08-15 11:32:40 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2011-08-15 12:59:50 +0800 |
commit | 99c7e2ac2625f8b22782972dc98b0ff8d11165a2 (patch) | |
tree | cf2b5af039bff12f352c17632927afcef091af85 /src/lookup | |
parent | aa0c5a5e74ddb8f3523d09dc67008afed304f2f2 (diff) | |
download | libpinyin-99c7e2ac2625f8b22782972dc98b0ff8d11165a2.tar.gz libpinyin-99c7e2ac2625f8b22782972dc98b0ff8d11165a2.tar.xz libpinyin-99c7e2ac2625f8b22782972dc98b0ff8d11165a2.zip |
change uni-gram computing from float to double in phrase and pinyin lookup
Diffstat (limited to 'src/lookup')
-rw-r--r-- | src/lookup/phrase_lookup.cpp | 10 | ||||
-rw-r--r-- | src/lookup/pinyin_lookup.cpp | 11 |
2 files changed, 11 insertions, 10 deletions
diff --git a/src/lookup/phrase_lookup.cpp b/src/lookup/phrase_lookup.cpp index c176773..e1c4604 100644 --- a/src/lookup/phrase_lookup.cpp +++ b/src/lookup/phrase_lookup.cpp @@ -180,9 +180,9 @@ phrase_token_t token){ 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) + gdouble elem_poss = m_cache_phrase_item.get_unigram_frequency() / (gdouble) m_phrase_index->get_phrase_index_total_freq(); - if ( elem_poss < FLT_EPSILON ) + if ( elem_poss < DBL_EPSILON ) return false; lookup_value_t next_value; @@ -197,10 +197,10 @@ bool PhraseLookup::bigram_gen_next_step(int nstep, lookup_value_t * cur_value, p 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) m_phrase_index->get_phrase_index_total_freq(); + gdouble unigram_poss = m_cache_phrase_item.get_unigram_frequency() / + (gdouble) m_phrase_index->get_phrase_index_total_freq(); - if ( bigram_poss < FLT_EPSILON && unigram_poss < FLT_EPSILON ) + if ( bigram_poss < FLT_EPSILON && unigram_poss < DBL_EPSILON ) return false; lookup_value_t next_value; diff --git a/src/lookup/pinyin_lookup.cpp b/src/lookup/pinyin_lookup.cpp index 10d61b4..7b8e623 100644 --- a/src/lookup/pinyin_lookup.cpp +++ b/src/lookup/pinyin_lookup.cpp @@ -325,9 +325,9 @@ bool PinyinLookup::unigram_gen_next_step(int nstep, lookup_value_t * cur_step, p 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) + gdouble elem_poss = m_cache_phrase_item.get_unigram_frequency() / (gdouble) m_phrase_index->get_phrase_index_total_freq(); - if ( elem_poss < FLT_EPSILON ) + if ( elem_poss < DBL_EPSILON ) return false; gfloat pinyin_poss = m_cache_phrase_item.get_pinyin_possibility(*m_custom, pinyinkeys); if (pinyin_poss < FLT_EPSILON ) @@ -345,9 +345,10 @@ bool PinyinLookup::bigram_gen_next_step(int nstep, lookup_value_t * cur_step, ph 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) - m_phrase_index->get_phrase_index_total_freq(); - if ( bigram_poss < FLT_EPSILON && unigram_poss < FLT_EPSILON ) + gdouble unigram_poss = m_cache_phrase_item.get_unigram_frequency() / + (gdouble) m_phrase_index->get_phrase_index_total_freq(); + + if ( bigram_poss < FLT_EPSILON && unigram_poss < DBL_EPSILON ) return false; gfloat pinyin_poss = m_cache_phrase_item.get_pinyin_possibility(*m_custom, pinyinkeys); if ( pinyin_poss < FLT_EPSILON ) |