<commit_before>import csv, itertools
from poolReducer import poolReducer

lineupSpreadsheet = open('/Users/RyanRobertson21/Desktop/simpleball.csv')
lineupReader = csv.reader(lineupSpreadsheet)
playerDict = {}

for row in lineupReader:
    playerList = []
    if lineupReader.line_num == 1:
        continue
    playerList.append(row[1])
    playerList.append(row[3])
    playerList.append(float(row[5]))
    playerList.append(int(row[7]))
    playerDict[row[0]] = playerList

lineupSpreadsheet.close()

outfielders = {}
for ids in playerDict:
    if playerDict[ids][0] == 'OF':
        outfielders[ids] = playerDict[ids]

pitchers = {}
for ids in playerDict:
    if playerDict[ids][0] == 'P':
        pitchers[ids] = playerDict[ids]

catchers = {}
for ids in playerDict:
    if playerDict[ids][0] == 'C':
        catchers[ids] = playerDict[ids]

firstBase = {}
for ids in playerDict:
    if playerDict[ids][0] == '1B':
        firstBase[ids] = playerDict[ids]

secondBase = {}
for ids in playerDict:
    if playerDict[ids][0] == '2B':
        secondBase[ids] = playerDict[ids]

shortStop = {}
for ids in playerDict:
    if playerDict[ids][0] == 'SS':
        shortStop[ids] = playerDict[ids]

thirdBase = {}
for ids in playerDict:
    if playerDict[ids][0] == '3B':
        thirdBase[ids] = playerDict[ids]


print(len(thirdBase))

print(len(poolReducer(thirdBase, 30)))


outfielderGroups = list(itertools.combinations(outfielders, 3))

allLineups = list(itertools.product(outfielderGroups, pitchers, catchers, firstBase, secondBase, shortStop, thirdBase))

underCap = {}
for lineup in allLineups:
    salary = 0
    projectedPoints = 0
    for item in lineup:
        if type(item) == tuple:
            for of in item:
                salary += playerDict[of][3]
                projectedPoints += playerDict[of][2]
        else:
            salary += playerDict[item][3]
            projectedPoints += playerDict[item][2]
    if salary <= 35000:
        underCap[projectedPoints] = lineup


pp = max(underCap)
optimalLineup = underCap[pp]
capUsed = 0
for item in optimalLineup:
    if type(item) == tuple:
        for of in item:
            capUsed += playerDict[of][3]
            print(playerDict[of][0] + ": " + playerDict[of][1])
    else:
        capUsed += playerDict[item][3]
        print(playerDict[item][0] + ": " + playerDict[item][1])<commit_msg>Only Read in probable Pitchers<commit_after>import csv, itertools
from poolReducer import poolReducer

lineupSpreadsheet = open('/Users/RyanRobertson21/Desktop/simpleball.csv')
lineupReader = csv.reader(lineupSpreadsheet)
playerDict = {}

for row in lineupReader:
    playerList = []
    if lineupReader.line_num == 1:
        continue
    playerList.append(row[1])
    playerList.append(row[3])
    playerList.append(float(row[5]))
    playerList.append(int(row[7]))
    try:
        playerList.append(row[13])
    except IndexError:
        pass
    playerDict[row[0]] = playerList

lineupSpreadsheet.close()

outfielders = {}
for ids in playerDict:
    if playerDict[ids][0] == 'OF':
        outfielders[ids] = playerDict[ids]

pitchers = {}
for ids in playerDict:
    if playerDict[ids][0] == 'P':
        try:
            if playerDict[ids][4] == 'Yes':
                pitchers[ids] = playerDict[ids]
        except IndexError:
            pass

catchers = {}
for ids in playerDict:
    if playerDict[ids][0] == 'C':
        catchers[ids] = playerDict[ids]

firstBase = {}
for ids in playerDict:
    if playerDict[ids][0] == '1B':
        firstBase[ids] = playerDict[ids]

secondBase = {}
for ids in playerDict:
    if playerDict[ids][0] == '2B':
        secondBase[ids] = playerDict[ids]

shortStop = {}
for ids in playerDict:
    if playerDict[ids][0] == 'SS':
        shortStop[ids] = playerDict[ids]

thirdBase = {}
for ids in playerDict:
    if playerDict[ids][0] == '3B':
        thirdBase[ids] = playerDict[ids]


print(len(outfielders))
print(len(pitchers))
outfielderGroups = list(itertools.combinations(outfielders, 3))

allLineups = list(itertools.product(outfielderGroups, pitchers, catchers, firstBase, secondBase, shortStop, thirdBase))

underCap = {}
for lineup in allLineups:
    salary = 0
    projectedPoints = 0
    for item in lineup:
        if type(item) == tuple:
            for of in item:
                salary += playerDict[of][3]
                projectedPoints += playerDict[of][2]
        else:
            salary += playerDict[item][3]
            projectedPoints += playerDict[item][2]
    if salary <= 35000:
        underCap[projectedPoints] = lineup


pp = max(underCap)
optimalLineup = underCap[pp]
capUsed = 0
for item in optimalLineup:
    if type(item) == tuple:
        for of in item:
            capUsed += playerDict[of][3]
            print(playerDict[of][0] + ": " + playerDict[of][1])
    else:
        capUsed += playerDict[item][3]
        print(playerDict[item][0] + ": " + playerDict[item][1])
{'fraction_non_alphanumeric': 0.13250559739466722, 'fraction_numerical': 0.016079788316710766, 'mean_word_length': 3.1328847771236332, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '726780', 'n_tokens_mistral': 1662, 'n_tokens_neox': 1603, 'n_words': 358}