jaccardSimilarityMap method Null safety
Returns a hashmap of terms to Jaccard Similarity Index with this term
using a k-gram length of k.
Implementation
Map<Term, double> jaccardSimilarityMap(Iterable<Term> terms, [int k = 3]) {
final retVal = <Term, double>{};
final termGrams = kGrams(k);
for (final other in terms) {
final otherGrams = other.kGrams(k);
final intersection = termGrams.intersection(otherGrams);
final union = termGrams.union(otherGrams);
retVal[other] = intersection.length / union.length;
}
return retVal;
}