lengthSimilarity method Null safety

double lengthSimilarity(
  1. Term other
)

Returns the similarity in length between this string and other where: lengthSimilarity = 1 - lengthDistance.

Returns:

  • 1.0 if this and other are the same length; and
  • 0.0 if lengthDistance >= 1.0, i.e when other.length is less than 50% or more than 200% of length.

Implementation

double lengthSimilarity(Term other) {
  final ld = lengthDistance(other);
  return ld > 1 ? 0 : 1 - ld;
}