Function rustc_span::lev_distance::lev_distance_with_substrings
source · Expand description
Provides a word similarity score between two words that accounts for substrings being more meaningful than a typical Levenshtein distance. The lower the score, the closer the match. 0 is an identical match.
Uses the Levenshtein distance between the two strings and removes the cost of the length
difference. If this is 0 then it is either a substring match or a full word match, in the
substring match case we detect this and return 1
. To prevent finding meaningless substrings,
eg. “in” in “shrink”, we only perform this subtraction of length difference if one of the words
is not greater than twice the length of the other. For cases where the words are close in size
but not an exact substring then the cost of the length difference is discounted by half.
Returns None
if the distance exceeds the limit.