LevenshteinRanker#

class scikitplot.corpus.LevenshteinRanker(*, backend='auto', strict=False, use_normalized_text=True, score_cutoff=0.0)[source]#

Ranker by normalised Levenshtein similarity, with backend provenance.

Parameters:
backendstr, default=”auto”

Backend of scikitplot.levenshtein.rank.

strictbool, default=False

Raise instead of falling back when backend is unavailable.

use_normalized_textbool, default=True

Compare with normalized_text when a document has one.

score_cutofffloat, default=0.0

Minimum similarity in [0, 1].

Parameters:

Notes

Build it with make_levenshtein_ranker. Each hit records backend="levenshtein:<name>", the backend that computed its distance, which can differ from the requested one after a runtime fallback.

__call__(query, documents, config)[source]#

Return the best config.top_k documents for query.

Parameters:
querystr

Query text.

documentssequence of CorpusDocument

Candidates.

configRetrievalConfig

Supplies top_k.

Returns:
list of RetrievalHit

Ordered as scikitplot.levenshtein.rank orders them: similarity, then distance, then position.

Parameters:
Return type:

list[RetrievalHit]