Returns the current semantic vector for the provided word, or if the word
is not currently in the semantic space, a vector is added for it and
returned.

@param word a word

@return the {@code SemanticVector} for the provide word.
190350
private IntegerVector getSemanticVector(String word) {
        IntegerVector v = wordToMeaning.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 = wordToMeaning.get(word);
                if (v == null) {
                    v = (useSparseSemantics) 
                        ? new CompactSparseIntegerVector(vectorLength)
                        : new DenseIntVector(vectorLength);
                    wordToMeaning.put(word, v);
                }
            }
        }
        return v;
    }
1370152
public boolean add( T word )
    {
        Entry<T> o = new Entry<T>(word, tail.prev, tail);
        tail.prev.next = o;
        tail.prev = o;
        
        //set the size and set the index
        size++;
        index.put(word.getValue(), word);
        
        return true;
    }
466366
public WordNumberCollectorBundle addWord(String key, String word) {
        wordCollector.add(key, word);
        return this;
    }
175428
@Override
    public Collection<String> wordsNearestSum(String word, int n) {
        //INDArray vec = Transforms.unitVec(this.lookupTable.vector(word));
        INDArray vec = this.lookupTable.vector(word);
        return wordsNearestSum(vec, n);
    }
675877
public String getAmbiguityClass(final String word) {
    final TreeMultimap<Integer, String> mfTagMap = getOrderedMap(word);
    String ambiguityClass = null;
    if (!mfTagMap.isEmpty()) {
      StringJoiner sb = new StringJoiner("-");
      for (Map.Entry<Integer, String> entry : mfTagMap.entries()) {
        sb.add(entry.getValue());
      }
      ambiguityClass = sb.toString();
      //System.err.println(ambiguityClass);
    } else {
      ambiguityClass = "O";
    }
    return ambiguityClass;
  }
531340
public int indexOf(String word) {
        if (vocabulary.containsKey(word)) {
            return vocabulary.get(word).getHuffmanNode().getIdx();
        } else
            return -1;
    }
1145002
public T get(Object term) {
        // Check that an index vector does not already exist.
        T v = termToItem.get(term);
        if (v == null) {
            synchronized (this) {
                // Confirm that some other thread has not created an index
                // vector for this term.
                v = termToItem.get(term);
                if (v == null) {
                    // Generate the index vector for this term and store it.
                    v = generator.generate();
                    termToItem.put((String) term, v);
                }
            }
        }
        return v;
    }
851302
def word_to_vector(word):
    
    vector = []
    for char in list(word):
        vector.append(char2int(char))
    return vector
1045164
public Collection<String> wordsNearest(String word, int n) {
        return modelUtils.wordsNearest(word, n);
    }
86737
public static Word compile(Word word)
    {
        word.value = PosTagCompiler.compile(word.label, word.value);
//        switch (word.label)
//        {
//            case "ns":
//            case "nsf":
//            {
//                word.value = Predefine.TAG_PLACE;
//            }
//            break;
////            case "nz":
//            case "nx":
//            {
//                    word.value = Predefine.TAG_PROPER;
//            }
//            break;
//            case "nt":
//            case "ntc":
//            case "ntcf":
//            case "ntcb":
//            case "ntch":
//            case "nto":
//            case "ntu":
//            case "nts":
//            case "nth":
//            {
//                word.value = Predefine.TAG_GROUP;
//            }
//            break;
//            case "m":
//            case "mq":
//            {
//                    word.value = Predefine.TAG_NUMBER;
//            }
//            break;
//            case "x":
//            {
//                word.value = Predefine.TAG_CLUSTER;
//            }
//            break;
//            case "xx":
//            {
//                word.value = Predefine.TAG_OTHER;
//            }
//            break;
//            case "t":
//            {
//                    word.value = Predefine.TAG_TIME;
//            }
//            break;
//            case "nr":
//            case "nrf":
//            {
//                word.value = Predefine.TAG_PEOPLE;
//            }
//            break;
//        }
        return word;
    }
1147636
@SafeVarargs
    public final WordBuilder<I> append(Word<? extends I>... words) {
        if (words.length == 0) {
            return this;
        }

        int allLen = 0;
        for (Word<? extends I> w : words) {
            allLen += w.length();
        }

        ensureAdditionalCapacity(allLen);

        for (Word<? extends I> word : words) {
            int wLen = word.length();
            word.writeToArray(0, array, length, wLen);
            length += wLen;
        }

        return this;
    }
275376
public String getMap(String word){
		if(nameMap==null||!nameMap.containsKey(word))
			return word;
		else
			return nameMap.get(word);
	}
92892
public static List<Word> split(Word word){
        String value = GENERIC_TRIE.get(word.getText());
        if(value==null){
            return null;
        }
        List<Word> words = new ArrayList<>();
        for(String val : value.split("\\s+")){
            words.add(new Word(val));
        }
        if(words.isEmpty()){
            return null;
        }
        return words;
    }
971506
private Map<String,SemanticVector> loadText(File sspaceFile) 
        throws IOException {

        LOGGER.info("loading text TSS from " + sspaceFile);
        
        BufferedReader br = new BufferedReader(new FileReader(sspaceFile));
        String[] header = br.readLine().split("\\s+");
        int words = Integer.parseInt(header[0]);
        dimensions = Integer.parseInt(header[1]);
        
        Map<String,SemanticVector> wordToSemantics = 
            new HashMap<String,SemanticVector>(words, 2f);
        
        // read in each word
        for (String line = null; (line = br.readLine()) != null; ) {
            String[] wordAndSemantics = line.split("\\|");
            String word = wordAndSemantics[0];
            SemanticVector semantics = new SemanticVector(dimensions);

            LOGGER.info("loading " + wordAndSemantics.length + 
                " timesteps for word " + word); 

            for (int i = 1; i < wordAndSemantics.length; ++i) {
                String[] timeStepAndValues = wordAndSemantics[i].split(" ");
                long timeStep = Long.parseLong(timeStepAndValues[0]);
                updateTimeRange(timeStep);

                // Load that time step's vector.  Note that we make the
                // assumption here that even though the T-Space is serialized in
                // a dense format, that the vector data is actually sparse, and
                // so it will be more efficient to store it as such.
                Map<Integer,Double> sparseArray = new IntegerMap<Double>();

                for (int j = 1; j < timeStepAndValues.length; ++j) {
                    sparseArray.put(Integer.valueOf(j-1), 
                            Double.valueOf(timeStepAndValues[j]));
                }
                semantics.setSemantics(timeStep, sparseArray);
            }
            wordToSemantics.put(word,semantics);
        }
    
        return wordToSemantics;
    }
422912
protected static String toSingular(String word) {
		if (word.endsWith("ies")) { //$NON-NLS-1$
			return word.substring(0, word.length() - 3) + "y"; //$NON-NLS-1$
		}
		if (word.endsWith("s")) { //$NON-NLS-1$
			return word.substring(0, word.length() - 1);
		}
		return word;
	}
123136
private SparseIntegerVector getSemanticVector(String word) {
        SparseIntegerVector v = wordToSemantics.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 = wordToSemantics.get(word);
                if (v == null) {
                    v = new CompactSparseIntegerVector(Integer.MAX_VALUE);
                    wordToSemantics.put(word, v);
                }
            }
        }
        return v;
    }
241457
@Override
    public INDArray getWordVectorMatrix(String word) {
        // TODO: add variable UNK here
        int idx = 0;
        if (hasWord(word))
            idx = vocabCache.indexOf(word);
        else if (getUNK() != null)
            idx = vocabCache.indexOf(getUNK());
        else
            return null;

        int deviceId = Nd4j.getAffinityManager().getDeviceForCurrentThread();
        INDArray array = null;

        if (cachePerDevice > 0 && cacheWrtDevice.get(deviceId).containsKey(idx))
            return cacheWrtDevice.get(Nd4j.getAffinityManager().getDeviceForCurrentThread()).get(idx);

        array = storage.get(idx);

        if (cachePerDevice > 0) {
            // TODO: add cache here
            long arrayBytes = array.length() * array.data().getElementSize();
            if ((arrayBytes * cacheWrtDevice.get(deviceId).size()) + arrayBytes < cachePerDevice)
                cacheWrtDevice.get(deviceId).put(idx, array);
        }

        return array;
    }