euroeval.closest_match¶
source module euroeval.closest_match
Functions related to finding the closest match to a given string.
Functions
-
get_closest_match — Find the closest match to a given string.
source get_closest_match(string: str, options: c.Iterable[str], case_sensitive: bool, insertion_weight: int = 1, deletion_weight: int = 1, substitution_weight: int = 1) → tuple[str, int]
Find the closest match to a given string.
Parameters
-
string : str — The string to match.
-
options : c.Iterable[str] — The options to match against.
-
case_sensitive : bool — Whether to match case sensitively.
-
insertion_weight : int — The weight of insertions in the Levenshtein distance.
-
deletion_weight : int — The weight of deletions in the Levenshtein distance.
-
substitution_weight : int — The weight of substitutions in the Levenshtein distance.
Returns
-
tuple[str, int] — A pair (closest_match, distance) where closest_match is the closest match to the given string and distance is the Levenshtein distance between the two.