Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving efficency of RAKE #1751

Merged
merged 5 commits into from
Apr 13, 2024
Merged

Improving efficency of RAKE #1751

merged 5 commits into from
Apr 13, 2024

Conversation

sw5678
Copy link
Member

@sw5678 sw5678 commented Mar 11, 2024

Minor changes too the method to make it more efficient from the PR comments.

@a3957273
Copy link
Member

Hey @sw5678 , could you resolve the trailing space errors? I realise they weren't introduced in your commit.

});
});
const wordDegreeMatrix = Array(tokens.length).fill().map(() => Array(tokens.length).fill(0));
for (let p=0; p < phrases.length; p++) {
Copy link
Member

@a3957273 a3957273 Mar 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can improve the readability of this by using 'for of' loops instead of dealing with index loops:

for (let phrase of phrases) {
  for (let word1 of phrase) {
    for (let word2 of phrase) {
      wordDegreeMatrix[tokens.indexOf(word1)][tokens.indexOf(word2)]++;
    }
  }
}

This is the best of both worlds, the improved readability of forEach without sacrificing the 50% reduction in performance.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry have only just seen this now. Ill make the changes.

@a3957273
Copy link
Member

Very nice improvements!

@a3957273 a3957273 merged commit a429902 into gchq:master Apr 13, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants