예제 #1
0
def add_sabr_pitcher():
    pitcher_list = read_json('pitchers.json')['Pitcher']

    league_dic = read_json('league.json')

    league_pitcher_dic = league_dic['Pitcher']

    pf_list = read_json('parks.json')['Park']

    for league in league_pitcher_dic.values():
        league = calc_sabr_pitcher(league)

    for pitcher in pitcher_list:
        cor_pf = correct_pf(pitcher, pf_list, '登板')
        if not cor_pf:
            cor_pf = Decimal('1')
            print(pitcher['Name'])
            print(f'PF補正係数: {cor_pf}')
        pitcher = calc_sabr_pitcher(pitcher,
                                    league_pitcher_dic[pitcher['League']],
                                    cor_pf)

    write_json('league.json', league_dic)

    write_json('pitchers.json', {'Pitcher': pitcher_list})
예제 #2
0
def add_sabr_pitcher():
    # query as team 'summary' page or individual 'detail' page
    query_type = 'detail'

    pitcher_list = read_json('pitchers.json')['Pitcher']

    league_dic = read_json('league.json')

    league_pitcher_dic = league_dic['Pitcher']

    pf_list = read_json('parks.json')['Park']

    for league in league_pitcher_dic.values():
        league = calc_sabr_pitcher(league, query_type="summary")

    for pitcher in pitcher_list:
        # 暫定実装
        cor_pf = Decimal('1')
        if query_type == 'detail':
            cor_pf = calc_parkfactor(pitcher, pf_list, '登板')
        pitcher = calc_sabr_pitcher(pitcher,
                                    league_pitcher_dic[pitcher['League']],
                                    cor_pf, query_type)

    write_json('league.json', league_dic)

    write_json('pitchers.json', {'Pitcher': pitcher_list})
예제 #3
0
def add_sabr_hitter():
    # query as team 'summary' page or individual 'detail' page
    query_type = 'detail'
    hitter_list = read_json('hitters.json')['Hitter']

    league_dic = read_json('league.json')

    league_hitter_dic = league_dic['Hitter']

    pf_list = read_json('parks.json')['Park']

    for league in league_hitter_dic.values():
        league, league_rc, league_xr = calc_sabr_hitter(league)

    for hitter in hitter_list:
        # 暫定実装
        cor_pf = Decimal('1')
        if query_type == 'detail':
            cor_pf = calc_parkfactor(hitter, pf_list, '試合')
        hitter = calc_sabr_hitter(hitter, league_dic, league_rc, league_xr,
                                  cor_pf)

    write_json('league.json', league_dic)

    write_json('hitters.json', {'Hitter': hitter_list})
예제 #4
0
def update_team_park_records():
    pitcher_list = read_json('pitchers.json')['Pitcher']
    hitter_list = read_json('hitters.json')['Hitter']
    team_list = read_json('teams.json')['Team']

    sum_team_pitcher_dic = sum_team_records(pitcher_list)
    fix_rate_records(sum_team_pitcher_dic)
    sum_team_hitter_dic = sum_team_records(hitter_list)
    fix_rate_records(sum_team_hitter_dic)

    update_team_list(team_list, sum_team_pitcher_dic)
    update_team_list(team_list, sum_team_hitter_dic)

    write_json('teams.json', {'Team': team_list})

    with open('datasource/past_parks.json', 'r') as f:
        past_pf_dic = json.load(f)

    pf_list = []
    for team_dic in team_list:
        team = team_dic['チーム']

        total_score_pf = average_pf(past_pf_dic[HOME_DIC[team]], '得点PF')
        total_hr_pf = average_pf(past_pf_dic[HOME_DIC[team]], 'HRPF')

        pf_list.append({
            '球場': HOME_DIC[team],
            '得点PF': total_score_pf,
            'HRPF': total_hr_pf
        })

    write_json('parks.json', {'Park': pf_list})
예제 #5
0
def update_records_by_official():
    pitcher_list = read_json('pitchers.json')['Pitcher']
    hitter_list = read_json('hitters.json')['Hitter']

    team_list = read_json('teams.json')['Team']

    pitcher_list = update_pitcher_y_records(pitcher_list, team_list)
    hitter_list = update_hitter_y_records(hitter_list, team_list)

    write_json('pitchers.json', {'Pitcher': pitcher_list})
    write_json('hitters.json', {'Hitter': hitter_list})
예제 #6
0
def write_league_records():
    pitcher_list = read_json('pitchers.json')['Pitcher']

    hitter_list = read_json('hitters.json')['Hitter']

    league_pitcher_dic = sum_league_records(pitcher_list)
    league_hitter_dic = sum_league_records(hitter_list)

    league_dic = {'Pitcher': league_pitcher_dic, 'Hitter': league_hitter_dic}

    write_json('league.json', league_dic)
예제 #7
0
def add_sabr_hitter():
    hitter_list = read_json('hitters.json')['Hitter']

    league_dic = read_json('league.json')

    league_hitter_dic = league_dic['Hitter']

    pf_list = read_json('parks.json')['Park']

    for league in league_hitter_dic.values():
        league, league_rc, league_xr = calc_sabr_hitter(league)

    for hitter in hitter_list:
        cor_pf = correct_pf(hitter, pf_list, '試合')
        if not cor_pf:
            cor_pf = Decimal('1')
            print(hitter['Name'])
            print(f'PF補正係数: {cor_pf}')
        hitter = calc_sabr_hitter(hitter, league_dic, league_rc, league_xr,
                                  cor_pf)

    write_json('league.json', league_dic)

    write_json('hitters.json', {'Hitter': hitter_list})
예제 #8
0
def write_hitter_records():
    hitter_list = all_player_list('b')

    write_json('hitters.json', {'Hitter': hitter_list})
예제 #9
0
def write_pitcher_records():
    pitcher_list = all_player_list('p')

    write_json('pitchers.json', {'Pitcher': pitcher_list})
예제 #10
0
def write_hitter_records():
    hitter_list = extend_team_player_list('b')

    write_json('hitters.json', {'Hitter': hitter_list})
예제 #11
0
def write_pitcher_records():
    pitcher_list = extend_team_player_list('p')

    write_json('pitchers.json', {'Pitcher': pitcher_list})
예제 #12
0
def write_team_records():
    team_list = append_team_array()

    write_json('teams.json', {'Team': team_list})