From 0cfb67bd0636a4fd9c4239c91b8a3eeb18cff2f8 Mon Sep 17 00:00:00 2001 From: sw5678 <151949597+sw5678@users.noreply.github.com> Date: Fri, 12 Apr 2024 11:27:29 +0100 Subject: [PATCH] Improved readability and efficiency of RAKE --- src/core/operations/RAKE.mjs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/operations/RAKE.mjs b/src/core/operations/RAKE.mjs index d54143ae..3dd58c50 100644 --- a/src/core/operations/RAKE.mjs +++ b/src/core/operations/RAKE.mjs @@ -105,10 +105,10 @@ class RAKE extends Operation { // Generate word_degree_matrix and populate const wordDegreeMatrix = Array(tokens.length).fill().map(() => Array(tokens.length).fill(0)); - for (let p=0; p < phrases.length; p++) { - for (let w1=0; w1 < phrases[p].length; w1++) { - for (let w2=0; w2 < phrases[p].length; w2++) { - wordDegreeMatrix[tokens.indexOf(phrases[p][w1])][tokens.indexOf(phrases[p][w2])]++; + for (const phrase of phrases) { + for (const word1 of phrase) { + for (const word2 of phrase) { + wordDegreeMatrix[tokens.indexOf(word1)][tokens.indexOf(word2)]++; } } }