These methods are all measures of the difference (aka edit distance) between two strings.
Compute the Levenshtein distance between s1 and s2.
Levenshtein distance represents the number of insertions, deletions, and subsititutions required to change one word to another.
levenshtein_distance('berne', 'born') == 2 representing the transformation of the first e to o and the deletion of the second e.
See the Levenshtein distance article at Wikipedia for more details.
Compute the Damerau-Levenshtein distance between s1 and s2.
A modification of Levenshtein distance, Damerau-Levenshtein distance counts transpositions (such as ifhs for fish) as a single edit.
levenshtein_distance('fish', 'ifsh') == 2 as it would require a deletion and an insertion,
damerau_levenshtein_distance('fish', 'ifsh') == 1 as this counts as a transposition.
See the Damerau-Levenshtein distance article at Wikipedia for more details.
Compute the Hamming distance between s1 and s2.
Hamming distance is the measure of the number of characters that differ between two strings.
Typically Hamming distance is undefined when strings are of different length, but this implementation
considers extra characters as differing. For example
hamming_distance('abc', 'abcd') == 1.
See the Hamming distance article at Wikipedia for more details.
Compute the Jaro distance between s1 and s2.
Jaro distance is a string-edit distance that gives a floating point response in [0,1] where 0 represents two completely dissimilar strings and 1 represents identical strings.
Compute the Jaro-Winkler distance between s1 and s2.
Jaro-Winkler is a modification/improvement to Jaro distance, like Jaro it gives a floating point response in [0,1] where 0 represents two completely dissimilar strings and 1 represents identical strings.
See the Jaro-Winkler distance article at Wikipedia for more details.
Match Rating Approach (comparison)¶
Compare s1 and s2 using the match rating approach algorithm, returns
Trueif strings are considered equivalent or
Falseif not. Can also return
Noneif s1 and s2 are not comparable (length differs by more than 3).
The Match rating approach algorithm is an algorithm for determining whether or not two names are
pronounced similarly. Strings are first encoded using
match_rating_codex() then compared according to the MRA algorithm.
See the Match Rating Approach article at Wikipedia for more details.