protected int addWordToVocab ( String word ) { vocab [ vocabSize ] = new VocabWord ( word ) ; vocabSize ++ ; // Reallocate memory if needed if ( vocabSize + 2 >= vocabMaxSize ) { vocabMaxSize += 1000 ; VocabWord [ ] temp = new VocabWord [ vocabMaxSize ] ; System . arraycopy ( vocab , 0 , temp , 0 , vocabSize ) ; vocab = temp ; } vocabIndexMap . put ( word , vocabSize - 1 ) ; return vocabSize - 1 ; }
Adds a word to the vocabulary