edit_similarity#

scikitplot.corpus.edit_similarity(a, b, *, normalize=None, backend='auto')[source]#

Return 1 - levenshtein(a, b) / max(len(a), len(b)).

Parameters:
a, bstr

Strings to compare (Unicode code points).

normalize{None, “basic”, “squad”}, default=None

Normalisation applied to both strings first.

backend{“auto”, “python”}, default=”auto”

"auto" uses scikitplot.levenshtein when importable; "python" always uses the exact fallback. Both return the same value.

Returns:
float

In [0, 1]; 1.0 for two empty strings.

Raises:
TypeError

If a or b is not a str.

ValueError

For an unknown normalize or backend.

Parameters:
Return type:

float

See also

make_pairwise_ranker

Rank corpus documents with this function.

Examples

>>> edit_similarity("kitten", "sitting")
0.5714285714285714