From e6e5908dbcbeb717a443880469f584bbc50874f7 Mon Sep 17 00:00:00 2001 From: sspanak Date: Mon, 29 Apr 2024 15:09:01 +0300 Subject: [PATCH] the word normalization script now uses logarithmic scale instead of linear --- scripts/normalize-frequencies.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/normalize-frequencies.js b/scripts/normalize-frequencies.js index e3b47d7d..de0aae04 100644 --- a/scripts/normalize-frequencies.js +++ b/scripts/normalize-frequencies.js @@ -47,10 +47,10 @@ async function normalize({ fileName, maxAllowedFrequency }) { words.push({word, frequency}); } - const normalizationRatio = maxAllowedFrequency / maxWordFrequency; + const normalizationRatio = maxAllowedFrequency / Math.log(maxWordFrequency); for (word of words) { - word.frequency = Math.ceil(word.frequency * normalizationRatio); + word.frequency = Math.ceil(Math.log(word.frequency) * normalizationRatio); } return words;