def test_filter_duplicates_from_list(self): word_list = ['abcd', "a", "'", "austin", "austin"] self.assertEqual( 4, len(NLPConversionUtil.remove_duplicates_from_list(word_list))) word_list = ['abcd', "a", "'", "austin"] self.assertEqual( 4, len(NLPConversionUtil.remove_duplicates_from_list(word_list)))
def create_team_player_dict(self, team_roster, team_name, league): """ :param team_roster: Roster Object from sportsreference package :param team_name: UPPER CASE TEAM NAME i.e. YANKEES :param league: NFL/MLB/NHL/NBA :return: dictionary of specific players for a team """ team_player_dict: dict = {} for player in team_roster.players: try: # If the player doesn't have a name # TODO add ability to scrape for name if player.name == None: continue position = self.get_position(player) player_instance = Player(display=player.name, team=team_name, position=position, player_id=player.player_id) # Checking Duplicate Names if NLPConversionUtil().normalize_text(player_instance.display) in self.league_roster_dict: self.handle_duplicate_names(player_instance) else: team_player_dict[NLPConversionUtil().normalize_text(player_instance.display)] = vars( player_instance) except AttributeError as err: # Some players have a name as None in sportsreference dict print(team_name, err) return team_player_dict
def test_format_names(self): response = NLPConversionUtil().format_name("AJ GREEN") expected = "AJ Green" self.assertEqual(expected, response) response = NLPConversionUtil().format_name("LEBRON JAMES") expected = "Lebron James" self.assertEqual(expected, response) response = NLPConversionUtil().format_name("AJ GREEN JAMES") expected = "AJ Green James" self.assertEqual(expected, response)
def create_golfer_dict(male_url, female_url): """ Creating Golfer Set male and female :param url: :return: """ # desktop user-agent USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:65.0) Gecko/20100101 Firefox/65.0" # mobile user-agent MOBILE_USER_AGENT = "Mozilla/5.0 (Linux; Android 7.0; SM-G930V Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.125 Mobile Safari/537.36" headers = {"user-agent": USER_AGENT} resp = requests.get(male_url, headers=headers) golf_dict = {} if resp.status_code == 200: print(resp.content) soup = BeautifulSoup(resp.content, "html.parser") for index, value in enumerate(soup.find_all('tr')): if index == 0 or index == 1: print(value) continue try: golfer = value.text.split('\n')[1].lstrip() if ' *' in golfer: golfer = golfer.replace(' *', '') if 'HoF' in golfer: golfer = golfer.replace(' HoF', '') golf_dict[NLPConversionUtil().normalize_text(golfer)] = "MEN'S GOLF" except IndexError as err: print(err, value) resp = requests.get(female_url, headers=headers) if resp.status_code == 200: print(resp.content) soup = BeautifulSoup(resp.content, "html.parser") for index, value in enumerate(soup.find_all('tr')): if index == 0 or index == 1: print(value) continue try: golfer = value.text.split('\n')[1].lstrip() if ' *' in golfer: golfer = golfer.replace(' *', '') if 'HoF' in golfer: golfer = golfer.replace(' HoF', '') golf_dict[NLPConversionUtil().normalize_text(golfer)] = "WOMEN'S GOLF" except IndexError as err: print(err, value) return golf_dict
def create_nfl_nicknames_dict(): """ Source: https://en.wikipedia.org/wiki/List_of_baseball_nicknames :return: Nickname dict format: { nickname: Player Name The King: Lebron James } """ url = "https://en.wikipedia.org/wiki/List_of_NFL_nicknames" # desktop user-agent USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:65.0) Gecko/20100101 Firefox/65.0" # mobile user-agent MOBILE_USER_AGENT = "Mozilla/5.0 (Linux; Android 7.0; SM-G930V Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.125 Mobile Safari/537.36" headers = {"user-agent": USER_AGENT} resp = requests.get(url, headers=headers) nickname_dict = {} if resp.status_code == 200: print(resp.content) soup = BeautifulSoup(resp.content, "html.parser") for index, value in enumerate(soup.findAll('tr')): try: name_nickname_split: list = value.text.split('\n')[ 1::2] # Getting Between Values first_name = name_nickname_split[1] # Sample Format ' "Splash Brothers" (Curry and Klay Thompson), "Baby-Faced Assassin", "Chef Curry", "Steph", "The Golden Boy"' # Splitting between quotes, and taking odd values if '[' in name_nickname_split[0]: nick_names = re.sub(r'\[.*?\]', '', name_nickname_split[0]) if ' or ' in nick_names: nick_names = nick_names.split(' or ') for i in nick_names: nickname_dict[NLPConversionUtil().normalize_text( i)] = NLPConversionUtil.normalize_text(first_name) if '/' in nick_names: nick_names = nick_names.split('/') for i in nick_names: nickname_dict[NLPConversionUtil().normalize_text( i)] = NLPConversionUtil.normalize_text(first_name) except Exception as e: print(e) return nickname_dict
def test_alter_tags_to_proper_response_format(self): tag = [{ "type": "person", "value": "LEBRON JAMES", "isPrimary": False }, { "type": "person", "value": "LEBRON JAMES", "isPrimary": True }, { "type": "team", "value": "LOS ANGELES LAKERS", "isPrimary": True }] expected = [{ "type": "person", "value": "Lebron James", "isPrimary": True }, { "type": "team", "value": "Los Angeles Lakers", "isPrimary": True }] response = NLPConversionUtil().alter_tags_to_proper_response_format( tag) self.assertEqual(expected, response)
def test_filter_token_list_by_type(self): word_list = [{"type": 'PERSON'}, {"type": 'ORG'}, {"type": 'ORG'}] self.assertEqual( 1, len( NLPConversionUtil.filter_token_list_by_type( word_list, "PERSON")))
def test_filter_tokens_get_unique_text(self): sample_dict = [{ "type": "PERSON", "text": "AUSTIN" }, { "type": "PERSON", "text": "LEBRON JAMES STARS" }, { "type": "ORG", "text": "JESSE" }, { "type": "ORG", "text": "JESSE" }, { "type": "NOT_IMPORTANT", "text": "JESSE" }] response, token_set, token_concat_str = NLPConversionUtil( ).filter_nlp_entities_and_create_unique_entity_reference( sample_dict, {"PERSON"}) self.assertEqual(response, [{ 'type': 'PERSON', 'text': 'AUSTIN' }, { 'type': 'PERSON', 'text': 'LEBRON JAMES STARS' }, { 'type': 'PERSON', 'text': 'LEBRON JAMES' }]) self.assertTrue('AUSTIN' in token_set) self.assertTrue('LEBRON JAMES STARS' in token_set) self.assertEqual(token_concat_str, 'AUSTINLEBRON JAMES STARS')
def test_remove_duplicates_from_dict_list_multiple_tags_both_are_primary( self): sample_dict = [{ "type": "name", "value": "Austin", "isPrimary": True }, { "type": "name", "value": "Jesse", "isPrimary": True }, { "type": "name", "value": "Jesse", "isPrimary": True }] expected = [{ "type": "name", "value": "Austin", "isPrimary": True }, { "type": "name", "value": "Jesse", "isPrimary": True }] response = NLPConversionUtil( ).remove_duplicates_from_dict_list_based_on_key(sample_dict) self.assertEqual(expected, response)
def create_nba_coach_dict(): """ Source: https://en.wikipedia.org/wiki/List_of_nicknames_used_in_basketball :return: Nickname dict format: { nickname: Player Name The King: Lebron James } """ url = "https://en.wikipedia.org/wiki/List_of_National_Basketball_Association_head_coaches" # desktop user-agent USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:65.0) Gecko/20100101 Firefox/65.0" # mobile user-agent MOBILE_USER_AGENT = "Mozilla/5.0 (Linux; Android 7.0; SM-G930V Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.125 Mobile Safari/537.36" headers = {"user-agent": USER_AGENT} resp = requests.get(url, headers=headers) coach_dict = {} if resp.status_code == 200: print(resp.content) soup = BeautifulSoup(resp.content, "html.parser") for index, value in enumerate(soup.findAll('tr')): try: if 7 < index < 38: name, team = value.text.split('\n')[1::2][0:2] if '*' in name: name = name.replace('*', '') coach_dict[NLPConversionUtil().normalize_text(name)] = team except Exception as e: print(e) return coach_dict
def test_convert_tags_to_capital_case(self): tag = [{"type": "person", "value": "LEBRON JAMES"}] expected = [{"type": "person", "value": "Lebron James"}] response = NLPConversionUtil( ).conver_non_league_tags_to_Title_Case_and_format_names(tag) self.assertEqual(expected, response) tag = [{"type": "league", "value": "NFL"}] expected = [{"type": "league", "value": "NFL"}] response = NLPConversionUtil( ).conver_non_league_tags_to_Title_Case_and_format_names(tag) self.assertEqual(expected, response) tag = [{"type": "position", "value": "RB"}] expected = [{"type": "position", "value": "RB"}] response = NLPConversionUtil( ).conver_non_league_tags_to_Title_Case_and_format_names(tag) self.assertEqual(expected, response)
def test_remove_prefix_from_word(self): nlp_entity = {"type": "ORG", "text": "THE CLEVELAND BROWNS"} self.assertEqual( { "type": "ORG", "text": "CLEVELAND BROWNS" }, NLPConversionUtil().remove_prefix_from_word(nlp_entity))
def test_format_team_names(self): team = "PHILADELPHIA 76ERS" response = NLPConversionUtil().format_team_name(team) expected = "Philadelphia 76ers" self.assertEqual(expected, response) team = "SAN FRANCISCO 49ERS" response = NLPConversionUtil().format_team_name(team) expected = "San Francisco 49ers" self.assertEqual(expected, response) team = "NEW YORK YANKEES" response = NLPConversionUtil().format_team_name(team) expected = "New York Yankees" self.assertEqual(expected, response) team = "GOLDEN STATE WARRIORS" response = NLPConversionUtil().format_team_name(team) expected = "Golden State Warriors" self.assertEqual(expected, response)
def create_team_dict(is_team_upper_case: False): # TODO 8/11 --This Doesnt have Las Vegas Raiders if is_team_upper_case: teams = NHLTeams(2019) nhl_dict = create_team_dict_ref(teams) nhl_dict_upper = dict( (NLPConversionUtil().normalize_text(k), v.upper()) for k, v in nhl_dict.items()) save_dict(nhl_dict_upper, "NHL_team_dict") teams = NBATeams(2019) nba_dict = create_team_dict_ref(teams) nba_dict_upper = dict( (NLPConversionUtil().normalize_text(k), v.upper()) for k, v in nba_dict.items()) save_dict(nba_dict_upper, "NBA_team_dict") teams = NFLTeams(2019) nfl_dict = create_team_dict_ref(teams) nfl_dict_upper = dict( (NLPConversionUtil().normalize_text(k), v.upper()) for k, v in nfl_dict.items()) save_dict(nfl_dict_upper, "NFL_team_dict") teams = MLBTeams(2019) mlb_dict = create_team_dict_ref(teams) mlb_dict_upper = dict( (NLPConversionUtil().normalize_text(k), v.upper()) for k, v in mlb_dict.items()) save_dict(mlb_dict_upper, "MLB_team_dict") else: teams = NHLTeams(2019) nhl_dict = create_team_dict_ref(teams) nhl_dict_upper = dict((NLPConversionUtil().normalize_text(k), v) for k, v in nhl_dict.items()) save_dict(nhl_dict_upper, "NHL_team_dict") teams = NBATeams(2019) nba_dict = create_team_dict_ref(teams) nba_dict_upper = dict((NLPConversionUtil().normalize_text(k), v) for k, v in nba_dict.items()) save_dict(nba_dict_upper, "NBA_team_dict") teams = NFLTeams(2019) nfl_dict = create_team_dict_ref(teams) nfl_dict_upper = dict((NLPConversionUtil().normalize_text(k), v) for k, v in nfl_dict.items()) save_dict(nfl_dict_upper, "NFL_team_dict") teams = MLBTeams(2019) mlb_dict = create_team_dict_ref(teams) mlb_dict_upper = dict((NLPConversionUtil().normalize_text(k), v) for k, v in mlb_dict.items()) save_dict(mlb_dict_upper, "MLB_team_dict")
def create_city_team_dict(edit_existing: bool, is_team_upper_case: bool = False): if edit_existing: if is_team_upper_case: final = existing_team_dict nfl_abreviations_upper = dict( (NLPConversionUtil().normalize_text(k), v.upper()) for k, v in final['NFL'].items()) nba_abr_upper = dict( (NLPConversionUtil().normalize_text(k), v.upper()) for k, v in final['NBA'].items()) mlb_abv_upper = dict( (NLPConversionUtil().normalize_text(k), v.upper()) for k, v in final['MLB'].items()) nhl_ab_upper = dict( (NLPConversionUtil().normalize_text(k), v.upper()) for k, v in final['NHL'].items()) final = { 'NFL': nfl_abreviations_upper, 'NBA': nba_abr_upper, 'MLB': mlb_abv_upper, 'NHL': nhl_ab_upper } save_dict(final, "city_team_dict") else: final = existing_team_dict nfl_abreviations_upper = dict( (NLPConversionUtil().normalize_text(k), v) for k, v in final['NFL'].items()) nba_abr_upper = dict((NLPConversionUtil().normalize_text(k), v) for k, v in final['NBA'].items()) mlb_abv_upper = dict((NLPConversionUtil().normalize_text(k), v) for k, v in final['MLB'].items()) nhl_ab_upper = dict((NLPConversionUtil().normalize_text(k), v) for k, v in final['NHL'].items()) final = { 'NFL': nfl_abreviations_upper, 'NBA': nba_abr_upper, 'MLB': mlb_abv_upper, 'NHL': nhl_ab_upper } save_dict(final, "city_team_dict") else: final = create_new_city_team_dict() save_dict(final, "city_team_dict")
def test_remove_word_from_key_word_text(self): sample_dict = { 'text': 'the Cleveland Browns', 'type': 'ORG', 'start_char': 46, 'end_char': 66 } expected = { 'text': 'Cleveland Browns', 'type': 'ORG', 'start_char': 46, 'end_char': 66 } response = NLPConversionUtil.remove_non_capitalized_words_from_nlp_entity_text( sample_dict) self.assertEqual(expected, response)
def test_remove_duplicates_from_dict_list(self): sample_dict = [{ "type": "name", "value": "Austin", "isPrimary": True }, { "type": "name", "value": "Jesse", "isPrimary": True }, { "type": "name", "value": "Jesse", "isPrimary": True }] self.assertEqual( 2, len(NLPConversionUtil(). remove_duplicates_from_dict_list_based_on_key(sample_dict)))
def test_convert_tags_to_capital_case(self): tag = [{"type": "person", "value": "LEBRON JAMES"}] expected = [{"type": "person", "value": "Lebron James"}] response = NLPConversionUtil( ).conver_non_league_tags_to_Title_Case_and_format_names(tag) self.assertEqual(expected, response) tag = [{"type": "person", "value": "LeBron James"}] expected = [{"type": "person", "value": "LeBron James"}] response = NLPConversionUtil( ).conver_non_league_tags_to_Title_Case_and_format_names(tag) self.assertEqual(expected, response) tag = [{"type": "league", "value": "NFL"}] expected = [{"type": "league", "value": "NFL"}] response = NLPConversionUtil( ).conver_non_league_tags_to_Title_Case_and_format_names(tag) self.assertEqual(expected, response) tag = [{"type": "position", "value": "RB"}] expected = [{"type": "position", "value": "RB"}] response = NLPConversionUtil( ).conver_non_league_tags_to_Title_Case_and_format_names(tag) self.assertEqual(expected, response) tag = [{"type": "team", "value": "SAN FRANCISCO 49ERS"}] expected = [{"type": "team", "value": "San Francisco 49ers"}] response = NLPConversionUtil( ).conver_non_league_tags_to_Title_Case_and_format_names(tag) self.assertEqual(expected, response) tag = [{"type": "team", "value": "PHILADELPHIA 76ERS"}] expected = [{"type": "team", "value": "Philadelphia 76ers"}] response = NLPConversionUtil( ).conver_non_league_tags_to_Title_Case_and_format_names(tag) self.assertEqual(expected, response) tag = [{"type": "team", "value": "NEW YORK YANKEES"}] expected = [{"type": "team", "value": "New York Yankees"}] response = NLPConversionUtil( ).conver_non_league_tags_to_Title_Case_and_format_names(tag) self.assertEqual(expected, response) tag = [{"type": "team", "value": "BOSTON CELTICS"}] expected = [{"type": "team", "value": "Boston Celtics"}] response = NLPConversionUtil( ).conver_non_league_tags_to_Title_Case_and_format_names(tag) self.assertEqual(expected, response)
def _scrape_sports_reference_for_roster(self, roster_url: str, team_name): soup = self._return_soup_object(roster_url) roster: dict = {} for index, table in enumerate(soup.find_all('tbody')): if index == 0: pass else: anchors = table.find_all('tr') for row in anchors: player_info = row.find('td', attrs={'data-stat': 'player'}) player_id = player_info.get('data-append-csv') name = player_info.a.get_text() position_info = row.find('td', attrs={'data-stat': 'pos'}) position = position_info.get_text().upper() if position not in FANTASY_FOOTBALL_POSITIONS: position = '' player_instance = Player(display=name, team=team_name, position=position, player_id=player_id) roster[NLPConversionUtil().normalize_text(player_instance.display)] = vars(player_instance) return roster
def create_mlb_coach_dict(): # TODO Issues with Same Manager Multiple Teams """ Source: https://en.wikipedia.org/wiki/List_of_nicknames_used_in_basketball :return: Nickname dict format: { nickname: Player Name The King: Lebron James } """ url = "https://en.wikipedia.org/wiki/List_of_Major_League_Baseball_managers" # desktop user-agent USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:65.0) Gecko/20100101 Firefox/65.0" # mobile user-agent MOBILE_USER_AGENT = "Mozilla/5.0 (Linux; Android 7.0; SM-G930V Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.125 Mobile Safari/537.36" headers = {"user-agent": USER_AGENT} resp = requests.get(url, headers=headers) coach_dict = {} if resp.status_code == 200: print(resp.content) soup = BeautifulSoup(resp.content, "html.parser") for index, value in enumerate(soup.findAll('tr')): try: if 0 < index < 16 or 16 < index < 32: team = value.text.split('\n')[1] try: name = value.text.split('\n')[6] old_name = value.text.split('\n')[11] except IndexError as e: print(e) name = value.text.split('\n')[5] old_name = value.text.split('\n')[9] coach_dict[NLPConversionUtil().normalize_text(name)] = team # coach_dict[old_name] = team except Exception as e: print(e) return coach_dict
def test_normalize_names_in_entity_list(self): sample_dict = [{ "type": "PERSON", "text": "Austin" }, { "type": "PERSON", "text": "Lebron James Stars" }, { "type": "PERSON", "text": "Lebron James Jr. Sr. iii, III" }, { "type": "ORG", "text": "Jesse" }, { "type": "ORG", "text": "Jesse" }, { "type": "NOT_IMPORTANT", "text": "Jesse" }] response = NLPConversionUtil().normalize_entity_list(sample_dict) expected = [{ 'type': 'PERSON', 'text': 'AUSTIN' }, { 'type': 'PERSON', 'text': 'LEBRON JAMES STARS' }, { 'type': 'PERSON', 'text': 'LEBRON JAMES' }, { "type": "ORG", "text": "JESSE" }, { "type": "ORG", "text": "JESSE" }, { "type": "NOT_IMPORTANT", "text": "JESSE" }] self.assertEqual(response, expected)
def test_normalize_name(self): self.assertEqual( "AJ GREEN", NLPConversionUtil().normalize_text( "A.J. GreEn Jr. Sr. III ii, iii '!?")) self.assertEqual("LEBRON JAMES", NLPConversionUtil().normalize_text(" Lebron JAmes ")) self.assertEqual( "LAURIE AYTON", NLPConversionUtil().normalize_text( "Laurie Ayton Jnr Snr jnr. snr.")) self.assertEqual("NYG@MIN", NLPConversionUtil().normalize_text("NYG@MIN")) self.assertEqual("AJ GREEN", NLPConversionUtil().normalize_text("A.J. Green's")) self.assertEqual( "TALEN HORTON-TUCKER", NLPConversionUtil().normalize_text("Talen Horton-Tucker"))
def create_headcoach_dict(is_team_upper_case=False): if is_team_upper_case: coach_dict = create_nfl_coach_dict() coach_dict_upper = dict((NLPConversionUtil().normalize_text(k), v.upper()) for k, v in coach_dict.items()) save_dict(coach_dict_upper, "NFL_coach_dict") coach_dict = create_nba_coach_dict() coach_dict_upper = dict((NLPConversionUtil().normalize_text(k), v.upper()) for k, v in coach_dict.items()) save_dict(coach_dict_upper, "NBA_coach_dict") coach_dict = create_mlb_coach_dict() coach_dict_upper = dict((NLPConversionUtil().normalize_text(k), v.upper()) for k, v in coach_dict.items()) save_dict(coach_dict_upper, "MLB_coach_dict") else: coach_dict = create_nfl_coach_dict() coach_dict_upper = dict((NLPConversionUtil().normalize_text(k), v) for k, v in coach_dict.items()) save_dict(coach_dict_upper, "NFL_coach_dict") coach_dict = create_nba_coach_dict() coach_dict_upper = dict((NLPConversionUtil().normalize_text(k), v) for k, v in coach_dict.items()) save_dict(coach_dict_upper, "NBA_coach_dict") coach_dict = create_mlb_coach_dict() coach_dict_upper = dict((NLPConversionUtil().normalize_text(k), v) for k, v in coach_dict.items()) save_dict(coach_dict_upper, "MLB_coach_dict")
def handle_duplicate_names(self, player_instance: Player): existing_player: dict = self.league_roster_dict[NLPConversionUtil().normalize_text(player_instance.display)] if existing_player["player_id"] == player_instance.player_id: # Getting the current team from sports reference, this issue happens when a player is on different # teams in the same season ex: MLB moralke01, so we are pulling from web page directly if this happens print("This is the Same person!", existing_player, vars(player_instance)) current_team = self._scrape_sports_reference_for_players_team(player_instance.player_id) print("Current Team Scraped from Sports Reference:", current_team) if current_team in self._get_valid_team_names(): formatted_team = NLPConversionUtil().normalize_text(current_team) self.league_roster_dict[NLPConversionUtil().normalize_text(player_instance.display)]["team"] \ = formatted_team else: del self.league_roster_dict[NLPConversionUtil().normalize_text(player_instance.display)] else: print("These are different people, welcome to the Michael Jordan Data quality issue, removing this " "person from Banter reference dictionary", existing_player, vars(player_instance)) self.duplicate_names.append(vars(player_instance)) self.duplicate_names.append( self.league_roster_dict[NLPConversionUtil().normalize_text(player_instance.display)]) del self.league_roster_dict[NLPConversionUtil().normalize_text(player_instance.display)]
def create_player_dict_on_teams(teams, league): player_dict = {} for team in teams: roster = team.roster for player in roster.players: try: position = PositionGenerator().get_position(player, league) player_dict[NLPConversionUtil().normalize_text(player.name)] = { "display": player.name, "team": NLPConversionUtil().normalize_text(team.name), "position": NLPConversionUtil().normalize_text( position)} except: # Some players have a name as None in sportsreference dict try: position = PositionGenerator().get_position(player, league) player_dict[NLPConversionUtil().normalize_text(player.name)] = { "display": player.name, "team": NLPConversionUtil().normalize_text(team.name), "position": NLPConversionUtil().normalize_text(position)} except: pass return player_dict
def test_filter_stop_words_and_punctuation(self): word_list = ['abcd', "a", "'", "austin"] self.assertEqual( 2, len(NLPConversionUtil.remove_stop_words_and_punctuation( word_list)))
def test_remove_non_capitalized_words(self): self.assertEqual( "Abc Def", NLPConversionUtil.remove_non_capitalized_words("Abc Def abd"))
def test_has_numbers(self): self.assertTrue(NLPConversionUtil().has_numbers("76ERS")) self.assertTrue(NLPConversionUtil().has_numbers("PHILADELPHIA 76ERS")) self.assertFalse(NLPConversionUtil().has_numbers("YANKEES")) self.assertFalse(NLPConversionUtil().has_numbers("NEW YORK YANKEES"))
def get_team_name(self, team_details: dict) -> str: return NLPConversionUtil().normalize_text(team_details["team_name"])
def test_remove_punctuation_from_text(self): sample_str = "My name's austin" self.assertEqual( "My names austin", NLPConversionUtil.remove_punctuation_from_text(sample_str))