private IntegerVector getSemanticVector ( String word ) { IntegerVector v = wordSpace . get ( word ) ; if ( v == null ) { // lock on the word in case multiple threads attempt to add it at // once synchronized ( this ) { // recheck in case another thread added it while we were waiting // for the lock v = wordSpace . get ( word ) ; if ( v == null ) { v = new CompactSparseIntegerVector ( vectorLength ) ; wordSpace . put ( word , v ) ; } } } return v ; }
Returns the current semantic vector for the provided word . If the word is not currently in the semantic space a vector is added for it and returned .