addTermKGrams method
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;
}
}