Improved readability and efficiency of RAKE

This commit is contained in:
sw5678 2024-04-12 11:27:29 +01:00
parent f606d4b25f
commit 0cfb67bd06

View file

@ -105,10 +105,10 @@ class RAKE extends Operation {
// Generate word_degree_matrix and populate // Generate word_degree_matrix and populate
const wordDegreeMatrix = Array(tokens.length).fill().map(() => Array(tokens.length).fill(0)); const wordDegreeMatrix = Array(tokens.length).fill().map(() => Array(tokens.length).fill(0));
for (let p=0; p < phrases.length; p++) { for (const phrase of phrases) {
for (let w1=0; w1 < phrases[p].length; w1++) { for (const word1 of phrase) {
for (let w2=0; w2 < phrases[p].length; w2++) { for (const word2 of phrase) {
wordDegreeMatrix[tokens.indexOf(phrases[p][w1])][tokens.indexOf(phrases[p][w2])]++; wordDegreeMatrix[tokens.indexOf(word1)][tokens.indexOf(word2)]++;
} }
} }
} }