termSimilarityMap method Null safety

Map<Term, double> termSimilarityMap(
  1. Iterable<Term> terms,
  2. [int k = 3]
)

a hashmap of terms to termSimilarity with this term using a k-gram length of k.

Implementation

Map<Term, double> termSimilarityMap(Iterable<Term> terms, [int k = 3]) {
  final retVal = <Term, double>{};
  final termGrams = kGrams(k);
  for (final other in terms) {
    retVal[other] =
        _jaccardSimilarity(termGrams, other, k) * termSimilarity(other);
  }
  return retVal;
}