private void addTokens(Queue<String> words,
                           int focusIndex,
                           int distance,
                           Map<Pair<Integer>, Double> matrixEntryToCount) {
        for (String word : words) {
            // skip adding co-occurence values for words that are not
            // accepted by the filter
            if (!word.equals(IteratorFactory.EMPTY_TOKEN)) {
                int index = termToIndex.getDimension(word);
                if (index >= 0) {
                    // Get the current number of times that the focus word has
                    // co-occurred with this word before after it.  Weight the
                    // word appropriately baed on distance
                    Pair<Integer> p = new Pair<Integer>(index, focusIndex);
                    double value = weighting.weight(distance, windowSize);
                    Double curCount = matrixEntryToCount.get(p);
                    matrixEntryToCount.put(p, (curCount == null)
                                           ? value : value + curCount);
                }
            }
            distance++;
        }
    }
private void addTokens ( Queue < String > words , int focusIndex , int distance , Map < Pair < Integer > , Double > matrixEntryToCount ) { for ( String word : words ) { if ( ! word . equals ( IteratorFactory . EMPTY_TOKEN ) ) { int index = termToIndex . getDimension ( word ) ; if ( index >= 0 ) { Pair < Integer > p = new Pair < Integer > ( index , focusIndex ) ; double value = weighting . weight ( distance , windowSize ) ; Double curCount = matrixEntryToCount . get ( p ) ; matrixEntryToCount . put ( p , ( curCount == null ) ? value : value + curCount ) ; } } distance ++ ; } }
Adds co-occurrence counts between the list of previous words in {@code
words} and the focus word represented by {@code focusIndex} which start
at {@code distance} tokens away from the focus word.  All Counts will be
added into {@code matrixEntryToCount}.