summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2018-04-10 13:59:37 +0800
committerPeng Wu <alexepico@gmail.com>2018-04-10 14:07:36 +0800
commitdff0311385bfab9fb898ecbef89b386ded5205c1 (patch)
tree26adbacdb3500a4647d39ef8ff21704d80485a65
parent3a41e1671aa3c71add07fc3dc09de6b71767b64a (diff)
downloadlibpinyin-dff0311385bfab9fb898ecbef89b386ded5205c1.zip
libpinyin-dff0311385bfab9fb898ecbef89b386ded5205c1.tar.gz
libpinyin-dff0311385bfab9fb898ecbef89b386ded5205c1.tar.xz
improve candidates sorting
-rw-r--r--src/pinyin.cpp5
1 files changed, 4 insertions, 1 deletions
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;