/** * @return Key = ngram, value = count * The order is as the n-grams appeared first in the string. * */ @NotNull public Map<String,Integer> extractCountedGrams(@NotNull CharSequence text) { text = applyPadding(text); int len = text.length(); int initialCapacity = 0; for (Integer gramLength : gramLengths) { initialCapacity += guessNumDistinctiveGrams(len, gramLength); } Map<String,Integer> grams = new LinkedHashMap<>(initialCapacity); for (Integer gramLength : gramLengths) { _extractCounted(text, gramLength, len, grams); } return grams; }
/** * @return Key = ngram, value = count * The order is as the n-grams appeared first in the string. * */ @NotNull public Map<String,Integer> extractCountedGrams(@NotNull CharSequence text) { text = applyPadding(text); int len = text.length(); int initialCapacity = 0; for (Integer gramLength : gramLengths) { initialCapacity += guessNumDistinctiveGrams(len, gramLength); } Map<String,Integer> grams = new LinkedHashMap<>(initialCapacity); for (Integer gramLength : gramLengths) { _extractCounted(text, gramLength, len, grams); } return grams; }
text = applyPadding(text); int len = text.length();
text = applyPadding(text); int len = text.length();