if (!focusWord.equals(IteratorFactory.EMPTY_TOKEN)) {
// Incorporate the context into the semantic vector for the
// focus word. If the focus word has no semantic vector yet,
// create a new one, as determined by the index builder.
DoubleVector meaning = termHolographs.get(focusWord);
if (meaning == null) {
meaning = new DenseVector(indexVectorSize);
documentVectors.put(focusWord, meaning);
}
updateMeaning(meaning, prevWords, nextWords);
}
prevWords.offer(focusWord);
if (prevWords.size() > 1)
prevWords.remove();
}
// Add the local cached semantics to the global term semantics.
for (Map.Entry<String, DoubleVector> entry :
documentVectors.entrySet()) {
synchronized (entry.getKey()) {
// Get the global semantic representation of each word. If it
// does not currently exist, then just put the local copies
// representation, otherwise add the local copy to the global
// version.
DoubleVector existingVector =
termHolographs.get(entry.getKey());
if (existingVector == null)
termHolographs.put(entry.getKey(), entry.getValue());
else
VectorMath.add(existingVector, entry.getValue());