Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorporate accent normalization/neutral search in players.find_players_by_(full/last/first)_name #484

Open
mxufc29 opened this issue Dec 3, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@mxufc29
Copy link

mxufc29 commented Dec 3, 2024

In the players.get_players() and players.find_players_by_(full/last/first)name functions, the list contains accented player names (Luka Dončić, Nikola Jokić, etc), and in order to correctly finding players by name, the input parameters must have the accents as well find_players_by_full_name('Jokic') returns empty). Since regex notation doesn't natively support accent removal, some suggestions to improve usability:
a) could players.find_players_by
(full/last/first)name functions incorporate accent neutral searching (input string unaccented matching to accented player name)? Adding a function such as the below:
"""
def strip_accents(inputstr: str) -> str:
normalizedstr = unicodedata.normalize('NFD', inputstr)
stripped = ''
return stripped.join(charx for charx in normalizedstr if unicodedata.category(charx) != 'Mn')
"""
or
b) could an additional entry be added to the static player list with the unaccented player name (if applicable)? then the players.find_players_by
(full/last/first)_name functions could attempt to match to both the accented and unaccented versions of the names.

@rsforbes
Copy link
Collaborator

rsforbes commented Dec 3, 2024

@mxufc29 - Thanks for calling this out.

I'd be in favor of option A, unicode normalized seach. This should be the most transparent way for the users so that anyone using accents for search would be oblivious to the modification.

If you're up for submitting a PR with a unit test, I'll review, merge, and get an update out.

@rsforbes rsforbes added the enhancement New feature or request label Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants