<commit_before>#!/usr/bin/env python

"""Module that controls getting stats and creating objects to hold that
information."""

import mlbgame.data
import mlbgame.object

import lxml.etree as etree

def __player_stats_info(data, name):
    home = []
    away = []
    for y in data:
        # loops through pitchers and batters
        for x in y.findall(name):
            stats = {}
            # loop through and save stats
            for i in x.attrib:
                stats[i] = x.attrib[i]
            # apply to correct list
            if y.attrib['team_flag'] == 'home':
                home.append(stats)
            elif not home:
                away.append(stats)
    return (home, away)

def __raw_player_stats_info(data):
    home_pitchers = []
    away_pitchers = []
    home_batters = []
    away_batters = []

    for team in data.findall('team'):
        home_flag = team.attrib['team_flag'] == 'home'
        pitching = team.find('pitching')
        for pitcher in pitching.findall('pitcher'):
            stats = {}
            for i in pitcher.attrib:
                stats[i] = pitcher.attrib[i]
            home_pitchers.append(stats) if home_flag else away_pitchers.append(stats)

        batting = team.find('batting')
        for batter in batting.findall('batter'):
            stats = {}
            for i in batter.attrib:
                stats[i] = batter.attrib[i]
            home_batters.append(stats) if home_flag else away_batters.append(stats)
    home = {
        'pitchers': home_pitchers,
        'batters': home_batters
    }

    away = {
        'pitchers': away_pitchers,
        'batters': away_batters<commit_msg>Fix check on team_flag, fixes #57<commit_after>#!/usr/bin/env python

"""Module that controls getting stats and creating objects to hold that
information."""

import mlbgame.data
import mlbgame.object

import lxml.etree as etree

def __player_stats_info(data, name):
    home = []
    away = []
    for y in data:
        # loops through pitchers and batters
        for x in y.findall(name):
            stats = {}
            # loop through and save stats
            for i in x.attrib:
                stats[i] = x.attrib[i]
            # apply to correct list
            home.append(stats) if y.attrib['team_flag'] == 'home' else away.append(stats)
    return (home, away)

def __raw_player_stats_info(data):
    home_pitchers = []
    away_pitchers = []
    home_batters = []
    away_batters = []

    for team in data.findall('team'):
        home_flag = team.attrib['team_flag'] == 'home'
        pitching = team.find('pitching')
        for pitcher in pitching.findall('pitcher'):
            stats = {}
            for i in pitcher.attrib:
                stats[i] = pitcher.attrib[i]
            home_pitchers.append(stats) if home_flag else away_pitchers.append(stats)

        batting = team.find('batting')
        for batter in batting.findall('batter'):
            stats = {}
            for i in batter.attrib:
                stats[i] = batter.attrib[i]
            home_batters.append(stats) if home_flag else away_batters.append(stats)
    home = {
        'pitchers': home_pitchers,
        'batters': home_batters
    }

    away = {
        'pitchers': away_pitchers,
        'batters': away_batters
{'fraction_non_alphanumeric': 0.10660980810234541, 'fraction_numerical': 0.0006091989034419738, 'mean_word_length': 2.0749063670411987, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4578133', 'n_tokens_mistral': 1033, 'n_tokens_neox': 982, 'n_words': 254}