public LanguageProfileBuilder addGram(String ngram, int frequency) {
        Map<String, Integer> map = ngrams.get(ngram.length());
        if (map==null) {
            map = new HashMap<>();
            ngrams.put(ngram.length(), map);
        }
        Integer total = map.get(ngram);
        if (total==null) total = 0;
        total += frequency;
        map.put(ngram, total);
        return this;
    }
public LanguageProfileBuilder addGram ( String ngram , int frequency ) { Map < String , Integer > map = ngrams . get ( ngram . length ( ) ) ; if ( map == null ) { map = new HashMap < > ( ) ; ngrams . put ( ngram . length ( ) , map ) ; } Integer total = map . get ( ngram ) ; if ( total == null ) total = 0 ; total += frequency ; map . put ( ngram , total ) ; return this ; }
If the builder already has this ngram, the given frequency is added to the current count.