fixed the normalization script genrating -Infinity frequencies sometimes
This commit is contained in:
parent
a68254578e
commit
bf1007369d
1 changed files with 1 additions and 1 deletions
|
|
@ -50,7 +50,7 @@ async function normalize({ fileName, maxAllowedFrequency }) {
|
||||||
const normalizationRatio = maxAllowedFrequency / Math.log(maxWordFrequency);
|
const normalizationRatio = maxAllowedFrequency / Math.log(maxWordFrequency);
|
||||||
|
|
||||||
for (word of words) {
|
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;
|
return words;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue