From 5fb027039ab137160da8a865b69bff3a437064e1 Mon Sep 17 00:00:00 2001 From: theOehrly <23384863+theOehrly@users.noreply.github.com> Date: Sun, 30 Jun 2024 23:57:35 +0200 Subject: [PATCH] remove forgotten old fuzzy matcher --- fastf1/plotting/_base.py | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/fastf1/plotting/_base.py b/fastf1/plotting/_base.py index c980092ed..e1a4cdfc2 100644 --- a/fastf1/plotting/_base.py +++ b/fastf1/plotting/_base.py @@ -1,13 +1,9 @@ import unicodedata from typing import ( Dict, - List, - Sequence, - TypeVar + List ) -from rapidfuzz import fuzz - from fastf1.logger import get_logger from fastf1.plotting._constants.base import TeamConst @@ -52,32 +48,6 @@ def __init__( self.teams_by_normalized[team.normalized_value] = team -S = TypeVar('S', bound=str) - - -def _fuzzy_matcher(identifier: str, reference: Sequence[S]) -> S: - # do fuzzy string matching - key_ratios = list() - for existing_key in reference: - ratio = fuzz.ratio(identifier, existing_key) - key_ratios.append((ratio, existing_key)) - key_ratios.sort(reverse=True) - if ((key_ratios[0][0] < 35) - or (key_ratios[0][0] / key_ratios[1][0] < 1.2)): - # ensure that the best match has a minimum accuracy (35 out of - # 100) and that it has a minimum confidence (at least 20% - # better than second best) - raise KeyError - if key_ratios[0][0] != 100: - _logger.warning( - ("Correcting invalid user input " - f"'{identifier}' to '{key_ratios[0][1]}'." - ) - ) - best_matched_key = key_ratios[0][1] - return best_matched_key - - def _normalize_string(name: str) -> str: # removes accents from a string and returns the closest possible # ascii representation (https://stackoverflow.com/a/518232)