How edit distance and similarity are computed
Edit distance is the smallest number of single-character edits needed to turn one string into the other. The allowed edits are inserting a character, deleting one and substituting one for another, and each costs exactly one. The measure is usually called Levenshtein distance after the mathematician who defined it. It is what spell checkers, duplicate-customer matching and near-title grouping rely on when two strings have to be compared as a number.
Similarity divides the distance by the length of the longer string and subtracts that from one, and the exact figures used are printed on the formula line. Using the longer string as the denominator keeps the result between zero and one hundred percent even when the two inputs differ a lot in length.
You can compare in either of two units. The default counts user-perceived characters, so an emoji built from several joined code points is a single unit. The code point option treats every Unicode scalar separately, which splits those emoji apart and raises the distance. Because the same pair can score differently under the two settings, the comparison basis is always shown with the result, and older browsers without grapheme support fall back to code points and say so. Work grows with the product of both lengths, so each string is capped at 2,000 characters.
Frequently asked questions
One minus the edit distance divided by the length of the longer string, multiplied by one hundred. The formula line shows the actual numbers that went into it.
Yes. A joined emoji is one unit under the grapheme setting but several under code points, which increases the distance. The result always states which basis was used.