turicreate.toolkits.distances.levenshtein¶
-
turicreate.toolkits.distances.
levenshtein
(x, y)¶ Compute the Levenshtein distance between between strings. The distance is the number of insertion, deletion, and substitution edits needed to transform string x into string y. The mathematical definition of Levenshtein is recursive:
D(x,y)=d(|x|,|y|)d(i,j)=max(i,j),ifmin(i,j)=0d(i,j)=min{d(i−1,j)+1, d(i,j−1)+1, d(i−1,j−1)+I(xi≠yi)},elseParameters: - x : string
First input string.
- y : string
Second input string.
Returns: - out : float
Levenshtein distance between x and y.
References
Examples
>>> tc.distances.levenshtein("fossa", "fossil") 2.0