@Override
    public synchronized void addWordToIndex(int index, String word) {
        if (word == null || word.isEmpty())
            throw new IllegalArgumentException("Word can't be empty or null");



        if (!tokens.containsKey(word)) {
            VocabWord token = new VocabWord(1.0, word);
            tokens.put(word, token);
            wordFrequencies.incrementCount(word, (float) 1.0);
        }

        /*
            If we're speaking about adding any word to index directly, it means it's going to be vocab word, not token
         */
        if (!vocabs.containsKey(word)) {
            VocabWord vw = tokenFor(word);
            vw.setIndex(index);
            vocabs.put(word, vw);
            vw.setIndex(index);
        }

        if (!wordFrequencies.containsElement(word))
            wordFrequencies.incrementCount(word, 1);

        wordIndex.add(word, index);

    }
@ Override public synchronized void addWordToIndex ( int index , String word ) { if ( word == null || word . isEmpty ( ) ) throw new IllegalArgumentException ( "Word can't be empty or null" ) ; if ( ! tokens . containsKey ( word ) ) { VocabWord token = new VocabWord ( 1.0 , word ) ; tokens . put ( word , token ) ; wordFrequencies . incrementCount ( word , ( float ) 1.0 ) ; } if ( ! vocabs . containsKey ( word ) ) { VocabWord vw = tokenFor ( word ) ; vw . setIndex ( index ) ; vocabs . put ( word , vw ) ; vw . setIndex ( index ) ; } if ( ! wordFrequencies . containsElement ( word ) ) wordFrequencies . incrementCount ( word , 1 ) ; wordIndex . add ( word , index ) ; }
@param index
@param word