characterSimilarity property

double characterSimilarity

Returns the similarity between the collection of letters of term and other on a scale of 0.0 to 1.0.

Compares the characters in term and other by splitting each string into a set of its unique characters and finding the intersection between the two sets of characters.

  • Returns 1.0 if the two Strings are the same (term.trim().toLowerCase() == other.trim().toLowerCase()).
  • Returns 1.0 if the character set for term and the intersection have the same length AND term and other are the same length.
  • Returns 0.0 if the intersection is empty (no shared characters).
  • Returns the intersection length divided by the average length of the two character sets multiplied by the length similarity.

The two strings are converted to lower-case and trimmed for the comparison.

Not case sensitive.

Implementation

double get characterSimilarity;