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(i1,j)+1, d(i,j1)+1, d(i1,j1)+I(xiyi)},else
Parameters:
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