File tree 1 file changed +9
-14
lines changed
1 file changed +9
-14
lines changed Original file line number Diff line number Diff line change @@ -101,22 +101,17 @@ class RAKE extends Operation {
101
101
phrases = phrases . filter ( subArray => subArray . length > 0 ) ;
102
102
103
103
// 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
+
111
106
// 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 ) {
116
111
wordDegreeMatrix [ tokens . indexOf ( word1 ) ] [ tokens . indexOf ( word2 ) ] ++ ;
117
- } ) ;
118
- } ) ;
119
- } ) ;
112
+ }
113
+ }
114
+ }
120
115
121
116
// Calculate degree score for each token
122
117
const degreeScores = Array ( tokens . length ) . fill ( 0 ) ;
You can’t perform that action at this time.
0 commit comments