termSimilarity method Null safety

double termSimilarity(
  1. Term other,
  2. [int k = 2]
)

Returns a similarity index value between 0.0 and 1.0 using a k-gram length of k.

The termSimilarity is defined as the product of jaccardSimilarity, lengthSimilarity and editSimilarity.

A term similarity of 1.0 means the two terms are identical:

  • have the same characters in the same order (edit distance of 0);
  • are of equal in length; and
  • have an identical collection of k-grams.

Not case-sensitive.

Implementation

double termSimilarity(Term other, [int k = 2]) =>
    (jaccardSimilarity(other, k) * 2 +
        lengthSimilarity(other) * 3 +
        editSimilarity(other) * 5) /
    10;