Skip to content

Commit 485f30f

Browse files
author
tmikolov
committed
minor bug fix
1 parent 6261414 commit 485f30f

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

word2vec.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ void SortVocab() {
163163
train_words += vocab[a].cn;
164164
}
165165
}
166+
vocab_size++;
166167
vocab = (struct vocab_word *)realloc(vocab, vocab_size * sizeof(struct vocab_word));
167168
// Allocate memory for the binary tree construction
168169
for (a = 0; a < vocab_size; a++) {
@@ -385,8 +386,8 @@ void *TrainModelThread(void *id) {
385386
while (1) {
386387
word = ReadWordIndex(fi);
387388
if (feof(fi)) break;
388-
word_count++;
389389
if (word == -1) continue;
390+
word_count++;
390391
if (word == 0) break;
391392
// The subsampling randomly discards frequent words while keeping the ranking same
392393
if (sample > 0) {
@@ -681,4 +682,4 @@ int main(int argc, char **argv) {
681682
}
682683
TrainModel();
683684
return 0;
684-
}
685+
}

0 commit comments

Comments
 (0)