Skip to content

Commit bc6050b

Browse files
committed
Refactor use of Array constructor
1 parent 16dfa83 commit bc6050b

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

lib/node_modules/@stdlib/nlp/lda/lib/fit.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ function fit( iter, burnin, thin ) {
7979
this.ndSum[ d ] -= 1;
8080
this.nwSum[ topic ] -= 1;
8181

82-
prob = new Array( this.K );
82+
prob = [];
8383
for ( j = 0; j < this.K; j++ ) {
84-
prob[ j ] = ( this.nw.get( word, j ) + this.beta ) /
84+
prob.push( ( this.nw.get( word, j ) + this.beta ) /
8585
( this.nwSum[ j ] + wbeta ) *
8686
( this.nd.get( d, j ) + this.alpha ) /
87-
( this.ndSum[ d ] + kalpha );
87+
( this.ndSum[ d ] + kalpha ) );
8888
}
8989
for ( j = 1; j < this.K; j++ ) {
9090
prob[ j ] += prob[ j - 1 ];

lib/node_modules/@stdlib/nlp/lda/lib/init.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ function init() {
4040
var d;
4141
var i;
4242

43-
this.z = new Array( this.D );
43+
this.z = [];
4444
for ( d = 0; d < this.D; d++ ) {
45-
this.z[ d ] = [];
45+
this.z.push( [] );
4646
len = this.w[ d ].length;
4747

4848
// Initialize random topics...

lib/node_modules/@stdlib/nlp/lda/lib/lda.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ function lda( documents, K, options ) {
115115

116116
// Extract words & construct vocabulary:s
117117
vocab = [];
118-
w = new Array( D );
118+
w = [];
119119
pos = 0;
120120
for ( d = 0; d < D; d++ ) {
121-
w[ d ] = [];
121+
w.push( [] );
122122
wd = tokenize( documents[ d ] );
123123
nd = wd.length;
124124
for ( i = 0; i < nd; i++ ) {
@@ -195,7 +195,7 @@ function lda( documents, K, options ) {
195195
no = 10;
196196
}
197197

198-
ret = new Array( no );
198+
ret = [];
199199
skip = [];
200200
for ( i = 0; i < no; i++ ) {
201201
max = 0;
@@ -207,10 +207,10 @@ function lda( documents, K, options ) {
207207
}
208208
}
209209
skip.push( mid );
210-
ret[ i ] = {
210+
ret.push({
211211
'word': vocab[ mid ],
212212
'prob': max
213-
};
213+
});
214214
}
215215
return ret;
216216
}

0 commit comments

Comments
 (0)