From f54f909701453bac563c9cb5ec75fde23e087e8e Mon Sep 17 00:00:00 2001 From: siikamiika Date: Thu, 19 Oct 2017 18:35:42 +0300 Subject: merged mode: rewrite term frequency (use score) --- ext/bg/js/dictionary.js | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'ext/bg/js/dictionary.js') diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js index 97716e65..ee056273 100644 --- a/ext/bg/js/dictionary.js +++ b/ext/bg/js/dictionary.js @@ -318,21 +318,24 @@ function dictTagsSort(tags) { }); } -function dictJmdictTermTagsRare(tags) { - const rareTags = [ - 'ik', - 'iK', - 'ok', - 'oK', - 'io', - 'oik' - ]; +function dictTermTagScore(tags) { + let score = 0; + + const tagScores = { + 'ik': -5, + 'iK': -5, + 'ok': -5, + 'oK': -5, + 'io': -5, + 'oik': -5, + 'P': 10 + }; + for (const tag of tags) { - if (rareTags.includes(tag)) { - return true; - } + score += tagScores[tag] || 0; } - return false; + + return score; } function dictFieldSplit(field) { -- cgit v1.2.3