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"usesscikitplot.levenshteinwhen 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
aorbis not astr.- ValueError
For an unknown
normalizeorbackend.
- Parameters:
- Return type:
See also
make_pairwise_rankerRank corpus documents with this function.
Examples
>>> edit_similarity("kitten", "sitting") 0.5714285714285714