natural 7.0.7 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/natural/tfidf/tfidf.js +19 -0
- package/package.json +1 -1
|
@@ -132,6 +132,25 @@ class TfIdf {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
// Remove a document from the corpus
|
|
136
|
+
// Returns true if the document was found
|
|
137
|
+
// Returns false if the document was not found
|
|
138
|
+
removeDocument (key) {
|
|
139
|
+
// Find the document
|
|
140
|
+
const index = this.documents.findIndex(function (document) {
|
|
141
|
+
return document.__key === key
|
|
142
|
+
})
|
|
143
|
+
// If found, remove it
|
|
144
|
+
if (index > -1) {
|
|
145
|
+
this.documents.splice(index, 1)
|
|
146
|
+
// Invalidate the cache
|
|
147
|
+
this._idfCache = Object.create(null)
|
|
148
|
+
return true
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return false
|
|
152
|
+
}
|
|
153
|
+
|
|
135
154
|
// If restoreCache is set to true, all terms idf scores currently cached will be recomputed.
|
|
136
155
|
// Otherwise, the cache will just be wiped clean
|
|
137
156
|
addFileSync (path, encoding, key, restoreCache) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "natural",
|
|
3
3
|
"description": "General natural language (tokenizing, stemming (English, Russian, Spanish), part-of-speech tagging, sentiment analysis, classification, inflection, phonetics, tfidf, WordNet, jaro-winkler, Levenshtein distance, Dice's Coefficient) facilities for node.",
|
|
4
|
-
"version": "7.0
|
|
4
|
+
"version": "7.1.0",
|
|
5
5
|
"homepage": "https://github.com/NaturalNode/natural",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|