Python API#
Every public name lives in scikitplot.levenshtein. The generated
reference pages carry the full signatures; this page says what each one is for.
Metrics#
distance(a, b, *, backend="auto", strict=False) -> intUnit-cost Levenshtein edit distance between two strings, byte strings or sequences.
normalized_distance(a, b, ...) -> floatdistance / max(len(a), len(b))in[0, 1]; two empty inputs give0.0.normalized_similarity(a, b, ...) -> float1 - normalized_distance; two empty inputs give1.0.similarity(a, b, ...) -> intmax(len(a), len(b)) - distance(a, b).
Ranking#
rank(query, choices, *, key=None, limit=None, score_cutoff=0.0, backend="auto", strict=False) -> list[Match]Every choice ordered by similarity, then distance, then input position.
closest(query, choices, ...) -> Match or NoneThe first result of
rankwithlimit=1.MatchOne ranked result:
choice,distance,similarity,indexand thebackendthat actually computed the distance.
Backends#
backend_info(name="auto") -> BackendInfoCapability record of one backend;
"auto"describes the backend that would be used now.available_backends(*, include_gpl=True) -> tuple[BackendInfo, ...]Records for
internal,rapidfuzz,levenshtein(unlessinclude_gpl=False) andpython, in preference order.BackendInfoRead-only record:
name,available,version,license,implementationand, when unavailable,reason.to_dict()returns it as a mapping.
Corpus#
This module does not import Corpus. Corpus ranks documents with it through
scikitplot.corpus.make_levenshtein_ranker; see
Corpus integration.