Normalize franchise values in card generation
- Add FRANCHISE_NORMALIZE dict and helper function - Update FRANCHISE_LIST to return city-agnostic values - Update mlbteam_and_franchise() to normalize franchise Ensures new cards use normalized franchise format for AI roster matching 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
78eb8862e1
commit
48ec7375a1
@ -107,6 +107,47 @@ DEFAULT_RELIEVER_OPS = {
|
|||||||
5: 0.702, # Common
|
5: 0.702, # Common
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Franchise normalization: Convert city+team names to city-agnostic team names
|
||||||
|
# This enables cross-era player matching (e.g., 'Oakland Athletics' -> 'Athletics')
|
||||||
|
FRANCHISE_NORMALIZE = {
|
||||||
|
'Arizona Diamondbacks': 'Diamondbacks',
|
||||||
|
'Atlanta Braves': 'Braves',
|
||||||
|
'Baltimore Orioles': 'Orioles',
|
||||||
|
'Boston Red Sox': 'Red Sox',
|
||||||
|
'Chicago Cubs': 'Cubs',
|
||||||
|
'Chicago White Sox': 'White Sox',
|
||||||
|
'Cincinnati Reds': 'Reds',
|
||||||
|
'Cleveland Guardians': 'Guardians',
|
||||||
|
'Colorado Rockies': 'Rockies',
|
||||||
|
'Detroit Tigers': 'Tigers',
|
||||||
|
'Houston Astros': 'Astros',
|
||||||
|
'Kansas City Royals': 'Royals',
|
||||||
|
'Los Angeles Angels': 'Angels',
|
||||||
|
'Los Angeles Dodgers': 'Dodgers',
|
||||||
|
'Miami Marlins': 'Marlins',
|
||||||
|
'Milwaukee Brewers': 'Brewers',
|
||||||
|
'Minnesota Twins': 'Twins',
|
||||||
|
'New York Mets': 'Mets',
|
||||||
|
'New York Yankees': 'Yankees',
|
||||||
|
'Oakland Athletics': 'Athletics',
|
||||||
|
'Philadelphia Phillies': 'Phillies',
|
||||||
|
'Pittsburgh Pirates': 'Pirates',
|
||||||
|
'San Diego Padres': 'Padres',
|
||||||
|
'San Francisco Giants': 'Giants',
|
||||||
|
'Seattle Mariners': 'Mariners',
|
||||||
|
'St Louis Cardinals': 'Cardinals',
|
||||||
|
'St. Louis Cardinals': 'Cardinals',
|
||||||
|
'Tampa Bay Rays': 'Rays',
|
||||||
|
'Texas Rangers': 'Rangers',
|
||||||
|
'Toronto Blue Jays': 'Blue Jays',
|
||||||
|
'Washington Nationals': 'Nationals',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def normalize_franchise(franchise: str) -> str:
|
||||||
|
"""Convert city+team name to team-only (e.g., 'Oakland Athletics' -> 'Athletics')"""
|
||||||
|
return FRANCHISE_NORMALIZE.get(franchise, franchise)
|
||||||
|
|
||||||
D20_CHANCES = {
|
D20_CHANCES = {
|
||||||
'2': {
|
'2': {
|
||||||
'chances': 1,
|
'chances': 1,
|
||||||
@ -554,41 +595,41 @@ CLUB_LIST = {
|
|||||||
'4TM': 'None'
|
'4TM': 'None'
|
||||||
}
|
}
|
||||||
FRANCHISE_LIST = {
|
FRANCHISE_LIST = {
|
||||||
'ANA': 'Los Angeles Angels',
|
'ANA': 'Angels',
|
||||||
'ARI': 'Arizona Diamondbacks',
|
'ARI': 'Diamondbacks',
|
||||||
'ATH': 'Oakland Athletics',
|
'ATH': 'Athletics',
|
||||||
'ATL': 'Atlanta Braves',
|
'ATL': 'Braves',
|
||||||
'BAL': 'Baltimore Orioles',
|
'BAL': 'Orioles',
|
||||||
'BOS': 'Boston Red Sox',
|
'BOS': 'Red Sox',
|
||||||
'CHC': 'Chicago Cubs',
|
'CHC': 'Cubs',
|
||||||
'CHW': 'Chicago White Sox',
|
'CHW': 'White Sox',
|
||||||
'CIN': 'Cincinnati Reds',
|
'CIN': 'Reds',
|
||||||
'CLE': 'Cleveland Guardians',
|
'CLE': 'Guardians',
|
||||||
'COL': 'Colorado Rockies',
|
'COL': 'Rockies',
|
||||||
'DET': 'Detroit Tigers',
|
'DET': 'Tigers',
|
||||||
'FLA': 'Miami Marlins',
|
'FLA': 'Marlins',
|
||||||
'HOU': 'Houston Astros',
|
'HOU': 'Astros',
|
||||||
'KCR': 'Kansas City Royals',
|
'KCR': 'Royals',
|
||||||
'LAA': 'Los Angeles Angels',
|
'LAA': 'Angels',
|
||||||
'LAD': 'Los Angeles Dodgers',
|
'LAD': 'Dodgers',
|
||||||
'MIA': 'Miami Marlins',
|
'MIA': 'Marlins',
|
||||||
'MIL': 'Milwaukee Brewers',
|
'MIL': 'Brewers',
|
||||||
'MIN': 'Minnesota Twins',
|
'MIN': 'Twins',
|
||||||
'MON': 'Washington Nationals',
|
'MON': 'Nationals', # Expos -> Nationals franchise
|
||||||
'NYM': 'New York Mets',
|
'NYM': 'Mets',
|
||||||
'NYY': 'New York Yankees',
|
'NYY': 'Yankees',
|
||||||
'OAK': 'Oakland Athletics',
|
'OAK': 'Athletics',
|
||||||
'PHI': 'Philadelphia Phillies',
|
'PHI': 'Phillies',
|
||||||
'PIT': 'Pittsburgh Pirates',
|
'PIT': 'Pirates',
|
||||||
'SDP': 'San Diego Padres',
|
'SDP': 'Padres',
|
||||||
'SEA': 'Seattle Mariners',
|
'SEA': 'Mariners',
|
||||||
'SFG': 'San Francisco Giants',
|
'SFG': 'Giants',
|
||||||
'STL': 'St Louis Cardinals',
|
'STL': 'Cardinals',
|
||||||
'TBD': 'Tampa Bay Rays',
|
'TBD': 'Rays',
|
||||||
'TBR': 'Tampa Bay Rays',
|
'TBR': 'Rays',
|
||||||
'TEX': 'Texas Rangers',
|
'TEX': 'Rangers',
|
||||||
'TOR': 'Toronto Blue Jays',
|
'TOR': 'Blue Jays',
|
||||||
'WSN': 'Washington Nationals',
|
'WSN': 'Nationals',
|
||||||
'TOT': 'None',
|
'TOT': 'None',
|
||||||
'2 Tms': 'None',
|
'2 Tms': 'None',
|
||||||
'2TM': 'None',
|
'2TM': 'None',
|
||||||
@ -1176,7 +1217,7 @@ def mlbteam_and_franchise(mlbam_playerid):
|
|||||||
logger.debug(f'data: {data}')
|
logger.debug(f'data: {data}')
|
||||||
if data['currentTeam']['name'] in CLUB_LIST.values():
|
if data['currentTeam']['name'] in CLUB_LIST.values():
|
||||||
p_data['mlbclub'] = data['currentTeam']['name']
|
p_data['mlbclub'] = data['currentTeam']['name']
|
||||||
p_data['franchise'] = data['currentTeam']['name']
|
p_data['franchise'] = normalize_franchise(data['currentTeam']['name'])
|
||||||
else:
|
else:
|
||||||
logger.error(f'Could not set team for {mlbam_playerid}; received {data["currentTeam"]["name"]}')
|
logger.error(f'Could not set team for {mlbam_playerid}; received {data["currentTeam"]["name"]}')
|
||||||
else:
|
else:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user