From dff0311385bfab9fb898ecbef89b386ded5205c1 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Tue, 10 Apr 2018 13:59:37 +0800 Subject: improve candidates sorting --- src/pinyin.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/pinyin.cpp b/src/pinyin.cpp index 8e4c85b..c8f173d 100644 --- a/src/pinyin.cpp +++ b/src/pinyin.cpp @@ -29,6 +29,9 @@ using namespace pinyin; +/* reduce bigram frequency affects on candidates sorting */ +#define BIGRAM_FREQUENCY_DISCOUNT 0.1f + /* a glue layer for input method integration. */ typedef GArray * CandidateVector; /* GArray of lookup_candidate_t */ @@ -1504,7 +1507,7 @@ static void _compute_frequency_of_items(pinyin_context_t * context, assert (0 < total_freq); /* Note: possibility value <= 1.0. */ - guint32 freq = (lambda * bigram_poss + + guint32 freq = (lambda * bigram_poss * BIGRAM_FREQUENCY_DISCOUNT + (1 - lambda) * cached_item.get_unigram_frequency() / (gfloat) total_freq) * 256 * 256 * 256; -- cgit