1
0
Fork 0

fixed the normalization script genrating -Infinity frequencies sometimes

This commit is contained in:
sspanak 2024-05-17 09:50:14 +03:00
parent a68254578e
commit bf1007369d

View file

@ -50,7 +50,7 @@ async function normalize({ fileName, maxAllowedFrequency }) {
const normalizationRatio = maxAllowedFrequency / Math.log(maxWordFrequency);
for (word of words) {
word.frequency = Math.ceil(Math.log(word.frequency) * normalizationRatio);
word.frequency = word.frequency > 0 ? Math.ceil(Math.log(word.frequency) * normalizationRatio) : 0;
}
return words;