@nlpjs/utils
Advanced tools
Comparing version 4.17.7 to 4.17.8
{ | ||
"name": "@nlpjs/utils", | ||
"version": "4.17.7", | ||
"version": "4.17.8", | ||
"description": "NLP utils", | ||
@@ -30,3 +30,3 @@ "author": { | ||
}, | ||
"gitHead": "1d2f085cfcef0c8671b45e0dd4705da94bd56621", | ||
"gitHead": "2986658b5f578ff2ec45488204a3ef8e9535d427", | ||
"dependencies": { | ||
@@ -33,0 +33,0 @@ "@nlpjs/xtables": "^4.17.0", |
@@ -0,0 +0,0 @@ /* |
@@ -39,3 +39,3 @@ /* | ||
}; | ||
const vowels = { a: 1, e: 1, i: 1, o: 1, u: 1 }; | ||
const vowels = { a: 1, e: 1, i: 1, o: 1, u: 1, y: 1 }; | ||
const chars = {}; | ||
@@ -59,2 +59,4 @@ for (let i = 0; i < tokens.length; i += 1) { | ||
freqs.wordCharFreq = freqs.words / freqs.length; | ||
freqs.vowelOverConsonant = | ||
freqs.consonants > 0 ? freqs.vowels / freqs.consonants : 0; | ||
return freqs; | ||
@@ -74,2 +76,5 @@ } | ||
function gibberishScore(text) { | ||
if (text.length < 6) { | ||
return 0; | ||
} | ||
const tokens = normalize(text) | ||
@@ -80,14 +85,9 @@ .split(/[\s,.!?;:([\]'"¡¿)/]+/) | ||
const deviations = { | ||
wordChar: getDeviation(measures.wordCharFreq, 0.15, 0.25), | ||
vowel: getDeviation(measures.vowelFreq, 0.3, 0.45), | ||
unique: getDeviation(measures.uniqueFreq, 0.4, 0.55), | ||
consonant: getDeviation(measures.consonantFreq, 0.5, 0.7), | ||
wordChar: getDeviation(measures.wordCharFreq, 0.15, 0.3), | ||
unique: getDeviation(measures.uniqueFreq, 0.4, 1), | ||
vowelOverConsonant: getDeviation(measures.vowelOverConsonant, 0.5, 1.5), | ||
}; | ||
return Math.min( | ||
1, | ||
(deviations.wordChar + | ||
deviations.vowel + | ||
deviations.unique + | ||
deviations.consonant) / | ||
2 | ||
deviations.unique * 2 + deviations.wordChar + deviations.vowelOverConsonant | ||
); | ||
@@ -94,0 +94,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
58725