Skip to content

Commit a429902

Browse files
authored
Merge pull request #1751 from sw5678/master
2 parents edc23a8 + f6c5a04 commit a429902

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

src/core/operations/RAKE.mjs

+9-14
Original file line numberDiff line numberDiff line change
@@ -101,22 +101,17 @@ class RAKE extends Operation {
101101
phrases = phrases.filter(subArray => subArray.length > 0);
102102

103103
// Remove duplicate phrases
104-
const uniquePhrases = [...new Set(phrases.map(function (phrase) {
105-
return phrase.join(" ");
106-
}))];
107-
phrases = uniquePhrases.map(function (phrase) {
108-
return phrase.split(" ");
109-
});
110-
104+
phrases = phrases.unique();
105+
111106
// Generate word_degree_matrix and populate
112-
const wordDegreeMatrix = Array.from(Array(tokens.length), _ => Array(tokens.length).fill(0));
113-
phrases.forEach(function (phrase) {
114-
phrase.forEach(function (word1) {
115-
phrase.forEach(function (word2) {
107+
const wordDegreeMatrix = Array(tokens.length).fill().map(() => Array(tokens.length).fill(0));
108+
for (const phrase of phrases) {
109+
for (const word1 of phrase) {
110+
for (const word2 of phrase) {
116111
wordDegreeMatrix[tokens.indexOf(word1)][tokens.indexOf(word2)]++;
117-
});
118-
});
119-
});
112+
}
113+
}
114+
}
120115

121116
// Calculate degree score for each token
122117
const degreeScores = Array(tokens.length).fill(0);

0 commit comments

Comments
 (0)