addTermKGrams method

void addTermKGrams(
  1. String term,
  2. Iterable<String> kGrams
)

Iterates through the kGrams and:

  • gets the current entry if it exists, or initializes a new entry for the k-gram key; and
  • adds the term to the set of term references for the k-gram key.

Implementation

void addTermKGrams(String term, Iterable<String> kGrams) {
  for (final kGram in kGrams.toSet()) {
    final set = this[kGram] ?? {};
    set.add(term);
    this[kGram] = set;
  }
}