Returns the SequenceElement's frequency over training corpus

@param word the word to retrieve the occurrence frequency for
@return
171531
@Override
    public int wordFrequency(@NonNull String word) {
        // TODO: proper wordFrequency impl should return long, instead of int
        T element = extendedVocabulary.get(word);
        if (element != null)
            return (int) element.getElementFrequency();
        return 0;
    }
361439
@Override
    public Acceptance lookup(Word<? extends I> word) {
        State s = getState(word);
        if (s == null) {
            return Acceptance.DONT_KNOW;
        }
        return s.getAcceptance();
    }
421603
@Override
    public List<String> similarWordsInVocabTo(String word, double accuracy) {
        List<String> ret = new ArrayList<>();
        for (String s : vocabCache.words()) {
            if (MathUtils.stringSimilarity(word, s) >= accuracy)
                ret.add(s);
        }
        return ret;
    }
597644
public WordBuilder<I> repeatAppend(int num, Word<I> word) {
        if (num == 0) {
            return this;
        }

        int wLen = word.length();
        int allLen = wLen * num;

        ensureAdditionalCapacity(allLen);

        for (int i = num; i > 0; i--) {
            word.writeToArray(0, array, length, wLen);
            length += wLen;
        }

        return this;
    }
1226579
public static CoreDictionary.Attribute getAttribute(String word)
    {
        CoreDictionary.Attribute attribute = CoreDictionary.get(word);
        if (attribute != null) return attribute;
        return CustomDictionary.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;
    }
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;
  }
797806
public void addWord(String word) {
        if (!vocabulary.containsKey(word)) {
            VocabularyWord vw = new VocabularyWord(word);

            /*
                TODO: this should be done in different way, since this implementation causes minWordFrequency ultimate ignoral if markAsSpecial set to TRUE
            
                Probably the best way to solve it, is remove markAsSpecial option here, and let this issue be regulated with minWordFrequency
              */
            // vw.setSpecial(markAsSpecial);

            // initialize frequencyShift only if hugeModelExpected. It's useless otherwise :)
            if (hugeModelExpected)
                vw.setFrequencyShift(new byte[retentionDelay]);

            vocabulary.put(word, vw);



            if (hugeModelExpected && minWordFrequency > 1
                            && hiddenWordsCounter.incrementAndGet() % scavengerThreshold == 0)
                activateScavenger();

            return;
        }
    }
1242910
public static int getTermFrequency(String term)
    {
        Attribute attribute = get(term);
        if (attribute == null) return 0;
        return attribute.totalFrequency;
    }
777676
private String formatWordsFrequency(Map<String, AtomicInteger> frequency){
        StringBuilder str = new StringBuilder();
        if(frequency != null && !frequency.isEmpty()) {
            AtomicInteger c = new AtomicInteger();
            frequency
                    .entrySet()
                    .stream()
                    .sorted((a, b) -> b.getValue().get() - a.getValue().get())
                    .forEach(e -> str.append("\t").append(c.incrementAndGet()).append("、").append(e.getKey()).append("=").append(e.getValue()).append("\n"));
        }
        str.setLength(str.length()-1);
        return str.toString();
    }
396179
private static String irregularity(String word){
        if(Character.isDigit(word.charAt(0))){
            LOGGER.debug("词以数字开头，忽略："+word);
            return null;
        }
        if(word.startsWith("0x")
                || word.startsWith("0X")){
            LOGGER.debug("词为16进制，忽略："+word);
            return null;
        }
        if(word.endsWith("l")
                && isNumeric(word.substring(0, word.length()-1))){
            LOGGER.debug("词为long类型数字，忽略："+word);
            return null;
        }
        if(UNICODE.matcher(word).find()){
            LOGGER.debug("词为UNICODE字符编码，忽略："+word);
            return null;
        }
        switch (word){
            //I’ll do it. You'll see.
            case "ll": return "will";
            //If you’re already building applications using Spring.
            case "re": return "are";
            //package com.manning.sdmia.ch04;
            case "ch": return "chapter";
            //you find you’ve made a
            case "ve": return "have";
            //but it doesn’t stop there.
            case "doesn": return "does";
            //but it isn’t enough.
            case "isn": return "is";
            //<input type="text" name="firstName" /><br/>
            case "br": return null;
        }
        return word;
    }
944534
public static boolean insert(String word, String natureWithFrequency)
    {
        if (word == null) return false;
        if (HanLP.Config.Normalization) word = CharTable.convert(word);
        CoreDictionary.Attribute att = natureWithFrequency == null ? new CoreDictionary.Attribute(Nature.nz, 1) : CoreDictionary.Attribute.create(natureWithFrequency);
        if (att == null) return false;
        if (dat.set(word, att)) return true;
        if (trie == null) trie = new BinTrie<CoreDictionary.Attribute>();
        trie.put(word, att);
        return true;
    }
641796
private SemanticVector getSemanticVector(String word) {
        SemanticVector v = wordToMeaning.get(word);
        if (v == null) {
            v = (useSparseSemantics) 
                ? new SparseSemanticVector(vectorLength)
                : new DenseSemanticVector(vectorLength);
            wordToMeaning.put(word, v);
        }
        return v;
    }
940153
public String replace(String word) {
        int flags = 0;
        if (ignoreCase) {
            flags = flags | Pattern.CASE_INSENSITIVE;
        }
        return Pattern.compile(pattern, flags).matcher(word).replaceAll(replacement);
    }
64709
protected IWord getNextTheWord(IWord word) throws IOException
    {
        String wVal = word.getValue();
        int wLen = word.getValue().length();
        IWord dWord = null;

        //the only 'the' word
        if ( wLen == 1 ) {
            return _nextNumberWord(word);
        }

        //template like '第三'
        if ( wLen == 2 ) {
            if ( NumericUtil.isCNNumeric(wVal.charAt(1)) == -1
                    && ! StringUtil.isEnNumeric(wVal.charAt(1)) ) {
                return null;
            }

            //update the word's entity
            word.addEntity(Entity.E_THE_NUMBER);
            return _nextNumberWord(word);
        }

        //template like '第x个'
        IWord unit = dic.get(ILexicon.NUMBER_UNIT, ""+wVal.charAt(wLen-1));
        if ( unit != null ) {
            if ( ! NumericUtil.isCNNumericString(wVal, 1, wLen-1)
                    && ! StringUtil.isDigit(wVal, 1, wLen-1) ) {
                return null;
            }

            dWord = word;
            dWord.setEntity(unit.getEntity());
            return dWord;
        }

        //the left template '第xxx'
        if ( ! NumericUtil.isCNNumericString(wVal, 1, wLen)
                && ! StringUtil.isDigit(wVal, 1, wLen) ) {
            return null;
        }

        word.addEntity(Entity.E_THE_NUMBER);
        return _nextNumberWord(word);
    }
816552
public double[] getWordVector(String word) {
        INDArray r = getWordVectorMatrix(word);
        if (r == null)
            return null;
        return r.dup().data().asDouble();
    }
827354
public static int findReservedWordID(StringBuilder word) {
        char c = word.charAt(0);

        switch (c) {
        case 'a':
            if (matches(word, "and")) return AND;
            if (matches(word, "as")) return AS;
            break;
        case 'b':
            if(matches(word, "break")) return BREAK;
            break;
        case 'c':
            if (matches(word, "call")) return CALL;
            if (matches(word, "class___")) return CLASS;
            if (matches(word, "continue")) return CONTINUE;
            break;
        case 'd':
            if (matches(word, "define")) return DEFINE;
            break;
        case 'e':
            if (matches(word, "else")) return ELSE;
            break;
        case 'f':
            if (matches(word, "foreach")) return FOREACH;
            if (matches(word, "false")) return FALSE;
            break;
        case 'i':
            if (matches(word, "if")) return IF;
            if (matches(word, "import")) return IMPORT;
            if (matches(word, "in")) return IN;
            if (matches(word, "isa")) return ISA;
            break;
        case 'n':
            if (matches(word, "null")) return NULL;
            if (matches(word, "not")) return NOT;
            break;
        case 'o':
            if (matches(word, "or")) return OR;
            break;
        case 'r':
            if (matches(word, "reverse")) return REVERSE;
            break;
        case 't':
            if (matches(word, "true")) return TRUE;
            if (matches(word, "template")) return TEMPLATE;
            break;
        }

        return UNKNOWN;
    }