We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d38403c commit 0df16eaCopy full SHA for 0df16ea
lib/search.js
@@ -88,11 +88,15 @@ let getIdf = (word) => {
88
89
let createTfIdf = () => {
90
corpus.tfidf = {};
91
+ let idfCache = {};
92
+
93
Object.keys(corpus.fileWords).forEach((file) => {
94
corpus.tfidf[file] = {};
95
Object.keys(corpus.fileWords[file]).forEach((word) => {
- let tfidf = getTf(word, file) * getIdf(word);
- corpus.tfidf[file][word] = tfidf;
96
+ if(!(word in idfCache)) {
97
+ idfCache[word] = getIdf(word);
98
+ }
99
+ corpus.tfidf[file][word] = getTf(word, file) * idfCache[word];
100
});
101
102
};
0 commit comments