lml-lorca-nlp
Advanced tools
Comparing version 1.0.14 to 1.0.15
47
lorca.js
@@ -357,51 +357,4 @@ 'use strict'; | ||
corpusFrequency(token) | ||
{ | ||
var list = cachedList = cachedList || require('./dictionaries/frequencyListRAE50000.json', 'utf8'); | ||
if(token){ | ||
return list[token]; | ||
} else { | ||
if(!(this.out instanceof Array)){ | ||
this.words().get(); | ||
} | ||
for(var i = 0; i < this.out.length; i++){ | ||
if(this.out[i] instanceof Array){ | ||
for(var j = 0; j < this.out[i].length; j++){ | ||
if(list[this.out[i][j]] != undefined){ | ||
this.out[i][j] = list[this.out[i][j]]; | ||
} else { | ||
this.out[i][j] = 0; | ||
} | ||
} | ||
} else { | ||
if(list[this.out[i]] != undefined){ | ||
this.out[i]= list[this.out[i]]; | ||
} else { | ||
this.out[i] = 0; | ||
} | ||
} | ||
} | ||
} | ||
return this; | ||
} | ||
tfidf() | ||
{ | ||
if(!(this.out instanceof Array)){ | ||
var frequencies = this.words().concordance('relative').get(); | ||
} | ||
var idf = {}; | ||
for (var token in frequencies){ | ||
this.out[token] = -frequencies[token]/0.0001*Math.log(this.corpusFrequency(token)/0.001); | ||
} | ||
return this; | ||
} | ||
} | ||
module.exports = lorca; |
{ | ||
"name": "lml-lorca-nlp", | ||
"version": "1.0.14", | ||
"version": "1.0.15", | ||
"description": "NLP for Spanish", | ||
@@ -5,0 +5,0 @@ "main": "lorca.js", |
3529828
33
13262