Spaces:
Running
Running
| aux_global_id_to_code = { | |
| 7911: 'G', | |
| 7912: 'S', | |
| 7913: 'DB', | |
| 7914: 'D', | |
| 7915: 'T', | |
| 7916: 'C', | |
| 7917: 'F', | |
| 7918: 'E', | |
| 7919: 'L', | |
| 7920: 'M', | |
| 7921: 'B', | |
| 7922: 'H', | |
| 7925: 'PL', | |
| 7926: 'CL' | |
| } | |
| ball_kind = { | |
| -1: '-', | |
| 31: 'Fastball (4-seam)', | |
| 32: 'Slider', | |
| 33: 'Vertical Slider', | |
| 34: 'Slurve', | |
| 35: 'Curve', | |
| 36: 'Slow Curve', | |
| 37: 'Power Curve', | |
| 38: 'Knuckle Curve', | |
| 39: 'Forkball', | |
| 40: 'Splitter', | |
| 41: 'Changeup', | |
| 42: 'Sinker', | |
| 43: 'Screwball', | |
| 44: 'Palmball', | |
| 45: 'Knuckleball', | |
| 46: 'Shootball', | |
| 47: 'Fastball (2-seam)', | |
| 48: 'Fastball (1-seam)', | |
| 49: 'Cutter', | |
| 50: 'Eephus', # technically "super" eephus but I haven't encountered a normal one yet | |
| 51: 'Hard Sinker', | |
| 52: 'Hard Slider', | |
| } | |
| ball_kind_code = { | |
| -1: '-', | |
| 31: '4S', | |
| 32: 'SL', | |
| 33: 'VS', | |
| 34: 'SV', | |
| 35: 'CU', | |
| 36: 'SC', | |
| 37: 'PC', | |
| 38: 'KC', | |
| 39: 'FO', | |
| 40: 'FS', | |
| 41: 'CH', | |
| 42: 'SI', | |
| 43: 'SB', | |
| 44: 'PB', | |
| 45: 'KN', | |
| 46: 'SH', | |
| 47: '2S', | |
| 48: '1S', | |
| 49: 'FC', | |
| 50: 'EP', # technically "super" eephus but I haven't encountered a normal one yet | |
| 51: 'HS', | |
| 52: 'HL' | |
| } | |
| general_ball_kind = { | |
| -1: '-', | |
| 31: 'Fastball (4-seam)', | |
| 32: 'Slider', | |
| 33: 'Vertical Slider', | |
| 34: 'Slurve', | |
| 35: 'Curve', | |
| 36: 'Curve', | |
| 37: 'Curve', | |
| 38: 'Curve', | |
| 39: 'Splitter', | |
| 40: 'Splitter', | |
| 41: 'Changeup', | |
| 42: 'Sinker', | |
| 43: 'Screwball', | |
| 44: 'Palmball', | |
| 45: 'Knuckleball', | |
| 46: 'Sinker', | |
| 47: 'Sinker', | |
| 48: 'Sinker', | |
| 49: 'Cutter', | |
| 50: 'Eephus', # technically "super" eephus but I haven't encountered a normal one yet | |
| 51: 'Sinker', | |
| 52: 'Vertical Slider', | |
| } | |
| general_ball_kind_code = { | |
| -1: '-', | |
| 31: '4S', | |
| 32: 'SL', | |
| 33: 'VS', | |
| 34: 'SV', | |
| 35: 'CU', | |
| 36: 'CU', | |
| 37: 'CU', | |
| 38: 'CU', | |
| 39: 'FS', | |
| 40: 'FS', | |
| 41: 'CH', | |
| 42: 'SI', | |
| 43: 'SB', | |
| 44: 'PB', | |
| 45: 'KN', | |
| 46: 'SI', | |
| 47: 'SI', | |
| 48: 'SI', | |
| 49: 'FC', | |
| 50: 'EP', # technically "super" eephus but I haven't encountered a normal one yet | |
| 51: 'SI', | |
| 52: 'VS' | |
| } | |
| lr = {1: 'l', 2: 'r'} | |
| presult = { | |
| 0: 'None', | |
| 101: 'Foul', | |
| 102: 'Single', | |
| 103: 'Hit by pitch', | |
| 104: 'Double', | |
| 105: 'Triple', | |
| 106: 'Home run', | |
| 107: 'Error', | |
| 108: 'Groundout', | |
| 109: 'Flyout', | |
| 110: 'Lineout', | |
| 111: 'Groundout (Double play)', | |
| 112: 'Foul fly', | |
| 113: 'Foul line (?)', | |
| 114: 'Sacrifice bunt', | |
| 115: 'Sacrifice fly', | |
| 116: 'Swinging strike', | |
| 117: 'Looking strike', | |
| 118: 'Ball', | |
| 119: 'Walk', | |
| 120: 'Balk', | |
| 121: 'Batter interference', | |
| 122: 'Catcher interference', | |
| 123: 'Uncaught third strike', | |
| 124: 'Sacrifice hit error', | |
| 125: 'Sacrifice fly error', | |
| 126: "Fielder's choice", | |
| 128: "Sacrifice fielder's choice", | |
| 129: 'Bunt strikeout', | |
| 130: 'Swinging strikeout', | |
| 131: 'Looking strikeout', | |
| 133: 'Inside-the-park home run', | |
| 134: 'Pitcher delay', | |
| 135: 'Balk', | |
| 139: 'Intentional walk', | |
| 140: 'Groundout (Double play)', | |
| 141: 'Unknown' | |
| } | |
| def verify_and_return_presult(presults): | |
| for _presult in presults: | |
| assert _presult in presult.values(), f'{_presult} is invalid' | |
| return presults | |
| bresult = { | |
| 0: '空振り三振', | |
| 1: '単打', # 1b gb p | |
| 2: '単打', # 1b gb c | |
| 3: '単打', # 1b gb 1b | |
| 4: '単打', # 1b gb 2b | |
| 5: '単打', # 1b gb 3b? ld | |
| 6: '単打', # 1b gb ss | |
| 7: '単打', # 1b gb lf? ld | |
| 8: '単打', # 1b gb cf | |
| 9: '単打', # 1b gb rf | |
| 10: '2塁打', # 2b gb p | |
| 12: '2塁打', # 2b gb 1b | |
| 13: '2塁打', # 2b gb 2b | |
| 14: '2塁打', # 2b gb 3b? ld | |
| 15: '2塁打', # 2b gb ss | |
| 16: '2塁打', # 2b gb lf? ld | |
| 17: '2塁打', # 2b gb cf | |
| 18: '2塁打', # 2b gb rf | |
| 22: '3塁打', # 3b gb 2b | |
| 25: '3塁打', # 3b gb lf? ld | |
| 26: '3塁打', # 3b gb cf | |
| 27: '3塁打', # 3b gb rf | |
| 28: '本塁打(ランニング)', # ihr lf? | |
| 29: '本塁打(ランニング)', # ihr cf? | |
| 30: '本塁打(ランニング)', # ihr rf? | |
| 31: '空振り三振', | |
| 32: '振逃げ', | |
| 33: '振逃げ', | |
| 34: '四球', | |
| 35: 'フライ', # fb cf | |
| 36: '死球', | |
| 37: '打撃妨害', | |
| 38: '守備妨害', | |
| 39: '犠打野選', | |
| 40: 'ゴロ', #gb p | |
| 41: 'ゴロ', #gb c | |
| 42: 'ゴロ', #gb 1b | |
| 43: 'ゴロ', #gb 2b | |
| 44: 'ゴロ', #gb 3b | |
| 45: 'ゴロ', #gb ss | |
| 46: 'ゴロ', #gb lf | |
| 47: 'ゴロ', #gb cf | |
| 48: 'ゴロ', #gb rf | |
| 49: 'フライ', # fb p | |
| 50: 'フライ', # fb c | |
| 51: 'フライ', # fb 1b | |
| 52: 'フライ', # fb 2b | |
| 53: 'フライ', # fb 3b | |
| 54: 'フライ', # fb ss | |
| 55: 'フライ', # fb lf | |
| 56: 'フライ', # fb cf | |
| 57: 'フライ', # fb rf | |
| 58: 'ライナー', # ld p | |
| 60: 'ライナー', # ld 1b | |
| 61: 'ライナー', # ld 2b | |
| 62: 'ライナー', # ld 3b | |
| 63: 'ライナー', # ld ss | |
| 64: 'ライナー', # ld lf | |
| 66: 'ライナー', # ld rf | |
| 67: '犠打', | |
| 68: '犠打', | |
| 69: '犠打', | |
| 70: '犠打', | |
| 71: '犠打', | |
| 79: '犠飛', # sac fly lf | |
| 80: '犠飛', # sac fly cf | |
| 81:'犠飛', # sac fly rf | |
| 82: '邪飛', | |
| 83: '邪飛', | |
| 84: '邪飛', | |
| 85: '邪飛', | |
| 86: '邪飛', | |
| 87: '邪飛', | |
| 88: '邪飛', | |
| 90: '邪飛', | |
| 91: 'ゴロ(併殺打)', | |
| 92: 'ゴロ(併殺打)', | |
| 93: 'ゴロ(併殺打)', | |
| 94: 'ゴロ(併殺打)', | |
| 95: 'ゴロ(併殺打)', | |
| 96: 'ゴロ(併殺打)', | |
| 100: '失策出塁', | |
| 101: '失策出塁', | |
| 102: '失策出塁', | |
| 103: '失策出塁', | |
| 104: '失策出塁', | |
| 105: '失策出塁', | |
| 106: '失策出塁', | |
| 107: '失策出塁', | |
| 108: '失策出塁', | |
| 109: '野選', | |
| 110: '野選', | |
| 111: '野選', | |
| 112: '野選', | |
| 113: '野選', | |
| 114: '野選', | |
| 115: '犠打失策', | |
| 116: '犠飛失策', | |
| 208: '本塁打', # hr lf? | |
| 210: '本塁打', # hr cf? | |
| 212: '本塁打', # hr rf? | |
| 214: '見送り三振', | |
| 215: '犠打野選', | |
| 216: '犠打野選', | |
| 218: '犠打野選', | |
| 229: '振逃げ', | |
| 234: '邪直', | |
| 236: '邪直', | |
| 241: '3バント失敗', | |
| 258: '規則違反', | |
| 267: '打撃妨害', | |
| 338: '?' | |
| } | |
| game_kind = { | |
| 1: 'CL Regular Season', | |
| 2: 'PL Regular Season', | |
| 3: 'Nippon Series', | |
| 4: 'All-Star Game', | |
| 5: 'Spring Training', | |
| 11: 'Farm Championship', | |
| 26: 'Interleague', | |
| 35: 'CL Climax Series First Stage', | |
| 36: 'CL Climax Series Final Stage', | |
| 37: 'PL Climax Series First Stage', | |
| 38: 'PL Climax Series Final Stage' | |
| } | |
| ball_kind_code_to_color = { | |
| '-': 'C0', | |
| '4S': 'crimson', | |
| 'SL': 'gold', | |
| 'VS': 'khaki', | |
| 'SV': 'lightsteelblue', | |
| 'CU': 'paleturquoise', | |
| 'SC': 'royalblue', | |
| 'PC': 'turquoise', | |
| 'KC': 'rebeccapurple', | |
| 'FO': 'darkturquoise', | |
| 'FS': 'cadetblue', | |
| 'CH': 'mediumseagreen', | |
| 'SI': 'orange', | |
| 'SB': 'lightgreen', | |
| 'PB': 'yellowgreen', | |
| 'KN': 'mediumblue', | |
| 'SH': 'tomato', | |
| '2S': 'orangered', | |
| '1S': 'lightsalmon', | |
| 'FC': 'sienna', | |
| 'EP': 'darkgray', # technically "super" eephus but I haven't encountered a normal one yet | |
| 'HS': 'darkorange', | |
| 'HL': 'darkkhaki' | |
| } | |
| def get_text_color_from_color(color): | |
| if color in ['gold', 'khaki', 'paleturquoise', 'turquoise']: | |
| return 'black' | |
| return 'white' | |
| ball_kind_to_color = {ball_kind: ball_kind_code_to_color[ball_kind_code[code]] for code, ball_kind in ball_kind.items()} | |
| team_name_short = { | |
| 'G': 'Yomiuri', | |
| 'S': 'Yakult', | |
| 'DB': 'DeNA', | |
| 'D': 'Chunichi', | |
| 'T': 'Hanshin', | |
| 'C': 'Hiroshima', | |
| 'F': 'Nipponham', | |
| 'E': 'Rakuten', | |
| 'L': 'Seibu', | |
| 'M': 'Lotte', | |
| 'B': 'ORIX', | |
| 'H': 'SoftBank', | |
| 'PL': 'Pacific League', | |
| 'CL': 'Central League', | |
| 'WL': 'Western League', # Why is this in the data? | |
| 'EL': 'Eastern League', # Same with this | |
| } | |
| team_to_color = { | |
| 'G': '#f69727', | |
| 'S': '#abcd05', | |
| 'DB': '#004a8f', | |
| 'D': '#08b1e8', | |
| 'T': '#ffe100', | |
| 'C': '#f92b20', | |
| 'F': '#016299', | |
| 'E': '#7d001a', | |
| 'L': '#00214b', | |
| 'M': '#efefef', | |
| 'B': '#baa834', | |
| 'H': '#fcc700', | |
| 'PL': '#01a9e4', | |
| 'CL': '#129144', | |
| 'WL': '#552a8d', | |
| 'EL': '#068ed9' | |
| } | |
| team_names_short_to_color = {team_name: team_to_color[team] for team, team_name in team_name_short.items()} | |
| def get_text_color_from_team(team): | |
| if team in ['DB', 'F', 'L', 'E', 'DeNA', 'Nipponham', 'Seibu', 'Rakuten']: | |
| return 'white' | |
| else: | |
| return 'black' | |