-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated coaching efficiency eligibility to normalize player names
- Loading branch information
1 parent
1bbebe1
commit 8e4672c
Showing
7 changed files
with
41 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
__author__ = "Wren J. R. (uberfastman)" | ||
__email__ = "[email protected]" | ||
|
||
import re | ||
|
||
from utilities.constants import player_name_punctuation, player_name_suffixes | ||
from utilities.logger import get_logger | ||
from utilities.settings import settings | ||
|
||
|
@@ -35,3 +38,21 @@ def truncate_cell_for_display(cell_text: str, halve_max_chars: bool = False, ses | |
|
||
else: | ||
return cell_text | ||
|
||
|
||
def normalize_player_name(player_full_name: str) -> str: | ||
"""Remove all punctuation and name suffixes from player names, combine whitespace, and covert them to title case. | ||
""" | ||
regex_all_whitespace = re.compile(r"\s+") | ||
normalized_player_name: str = regex_all_whitespace.sub(" ", player_full_name).strip() | ||
|
||
if (any(punc in player_full_name for punc in player_name_punctuation) | ||
or any(suffix in player_full_name for suffix in player_name_suffixes)): | ||
|
||
for punc in player_name_punctuation: | ||
normalized_player_name = normalized_player_name.replace(punc, "") | ||
|
||
for suffix in player_name_suffixes: | ||
normalized_player_name = normalized_player_name.removesuffix(suffix) | ||
|
||
return normalized_player_name.strip().title() |