-
Notifications
You must be signed in to change notification settings - Fork 0
/
parseResults.py
102 lines (83 loc) · 3.99 KB
/
parseResults.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
from pprint import pprint
import operator
from json import dumps
assignments = {} ## email: [1, 2, 3, 4, 5]
hacks = {}
with open("hacks.csv", "r") as f:
for line in f.readlines():
cols = line.replace('\n', '').split('\t')
hacks[cols[0]] = {
"name": cols[1],
"innovation_betterThan": [],
"design_betterThan": [],
"overall_betterThan": [],
"judgeCount": 0
}
with open("assignments.csv", "r") as f:
for line in f.readlines():
cols = line.replace('\n', '').split('\t')
assignments[cols[1]] = cols[2:]
for c in assignments[cols[1]]:
hacks[c]["judgeCount"] += 1
with open("judging.csv", "r") as f:
for line in f.readlines():
cols = line.replace('\n', '').split('\t')
email = cols[2]
for i in range(0, 6):
# if 'isMobile' in hacks[ assignments[email][i] ]:
# if ("mobile" in cols[2*i+3].lower()) != hacks[ assignments[email][i] ]['isMobile']:
# print "ALERT: judge chose different value for mobile for hack at table "+assignments[email][i]
hacks[ assignments[email][i] ]['isMobile'] = ("mobile" in cols[2*i+3].lower())
# if 'isWeb' in hacks[ assignments[email][i] ]:
# if ("web" in cols[2*i+3].lower()) != hacks[ assignments[email][i] ]['isWeb']:
# print "ALERT: judge chose different value for web for hack at table "+assignments[email][i]
hacks[ assignments[email][i] ]['isWeb'] = ("web" in cols[2*i+3].lower())
# if 'isBeginner' in hacks[ assignments[email][i] ]:
# if ("mobile" in cols[2*i+4].lower()) != hacks[ assignments[email][i] ]['isBeginner']:
# print "ALERT: judge chose different value for mobile for hack at table "+assignments[email][i]
hacks[ assignments[email][i] ]['isBeginner'] = (cols[2*i+4].lower() == "yes")
innovationRanking = cols[15].replace(' ', '').split(',')
for i, n in enumerate(innovationRanking):
if i+1 < len(innovationRanking):
hacks[ n ]['innovation_betterThan'] += innovationRanking[i+1:]
designRanking = cols[16].replace(' ', '').split(',')
for i, n in enumerate(designRanking):
if i+1 < len(designRanking):
hacks[ n ]['design_betterThan'] += designRanking[i+1:]
overallRanking = cols[17].replace(' ', '').split(',')
for i, n in enumerate(overallRanking):
if i+1 < len(overallRanking):
hacks[ n ]['overall_betterThan'] += overallRanking[i+1:]
def innovationScore(hackNum):
score = 0
for n in hacks[ hackNum ]['innovation_betterThan']:
score += len(hacks[n]['innovation_betterThan']) / hacks[n]['judgeCount']; ## Average position of hack in rankings
return score
def designScore(hackNum):
score = 0
for n in hacks[ hackNum ]['design_betterThan']:
score += len(hacks[n]['design_betterThan']) / hacks[n]['judgeCount']; ## Average position of hack in rankings
return score
def overallScore(hackNum):
score = 0
for n in hacks[ hackNum ]['overall_betterThan']:
score += len(hacks[n]['overall_betterThan']) / hacks[n]['judgeCount']; ## Average position of hack in rankings
return score
for n in hacks:
hacks[n]['designScore'] = designScore(n);
hacks[n]['innovationScore'] = innovationScore(n);
hacks[n]['overallScore'] = overallScore(n);
designList = sorted(hacks.values(), key=lambda (item): -1 * item['designScore']);
innovationList = sorted(hacks.values(), key=lambda (item): -1 * item['innovationScore']);
overallList = sorted(hacks.values(), key=lambda (item): -1 * item['overallScore']);
print "Design Ranking:"
for i in range(0, 10):
pprint(designList[i]["name"]);
print "\nInnovation Ranking:"
for i in range(0, 10):
pprint(innovationList[i]["name"]);
print "\nOverall Ranking:"
for i in range(0, 10):
pprint(overallList[i]["name"]);
with open("data.json", "w") as outFile:
outFile.write(dumps(hacks))