Skip to content

Commit 6b541b2

Browse files
committed
ASA-150: set minimum match score
1 parent 23c4b09 commit 6b541b2

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

python-package/itscalledsoccer/client.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def _convert_name_to_id(self, type: str, name: str) -> Union[str, int]:
5757
:param name: name
5858
:returns: either an int or string, depending on the type
5959
"""
60+
min_score = 70
6061
if type == "player":
6162
lookup = self.players
6263
names = self.players.keys()
@@ -74,7 +75,15 @@ def _convert_name_to_id(self, type: str, name: str) -> Union[str, int]:
7475
names = self.teams.keys()
7576

7677
matches = process.extractOne(name, names, scorer=fuzz.partial_ratio)
77-
lookup_id = matches[0]
78+
if matches:
79+
if matches[1] > min_score:
80+
lookup_id = matches[0]
81+
else:
82+
print(f"No match found for {name}")
83+
return ""
84+
else:
85+
print(f"No match found for {name}")
86+
return ""
7887
matched_id = lookup.get(lookup_id)
7988
return matched_id
8089

0 commit comments

Comments
 (0)