Skip to content

Commit

Permalink
remove forgotten old fuzzy matcher
Browse files Browse the repository at this point in the history
  • Loading branch information
theOehrly committed Jun 30, 2024
1 parent a7d102a commit 5fb0270
Showing 1 changed file with 1 addition and 31 deletions.
32 changes: 1 addition & 31 deletions fastf1/plotting/_base.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 5fb0270

Please sign in to comment.