1414
1515# categories that are combos of other categories
1616BIG_CATEGORIES = [
17- ("Science" , ["Biology" , "Chemistry" , "Physics" , "Other Science" ]),
17+ ("Science and Math" , [
18+ "Biology" , "Chemistry" , "Physics" , "Other Science" , "Astronomy" , "Math" ,
19+ "Earth Science" , "Computer Science"
20+ ]),
1821 ("Literature" , [
1922 "American Literature" , "British Literature" , "European Literature" ,
2023 "World Literature" , "Other Literature" , "World/Other Literature" ,
21- "Ancient/Other Literature" ,
24+ "Ancient/Other Literature" , "British/Commonwealth Literature" ,
25+ "American - Drama Literature" , "American - Long Fiction Literature" ,
26+ "American - Poetry Literature" , "American - Short Story Literature" ,
27+ "American - Short Story/Long Fiction Literature" , "British - Drama Literature" ,
28+ "British - Long Fiction Literature" , "British - Poetry Literature" ,
29+ "British - Short Story Literature" , "Classical Literature" ,
30+ "European - Drama Literature" , "European - Long Fiction Literature" ,
31+ "European - Poetry Literature" , "European - Short Story Liiterature" ,
32+ "Mixed Literature" , "World - Drama Literature" , "World - Long Fiction Literature" ,
33+ "World - Poetry Literature" , "World - Short Story Literature" ,
34+ "World- Long Fiction Literature"
2235 ]),
2336 ("History" , [
2437 "American History" , "World History" , "European History" , "Other History" ,
25- "Ancient History" , "Ancient/Other History"
38+ "Ancient History" , "Ancient/Other History" , "History - American" , "History - Ancient" ,
39+ "History - European" , "History - Other" , "History - World" , "Cross History" ,
40+ "Cross/Historiography History" , "European History History"
2641 ]),
2742 ("Fine Arts" , [
2843 "Painting/Sculpture" , "Other Fine Arts" , "Classical Music" , "Visual Fine Arts" ,
29- "Auditory Fine Arts"
44+ "Auditory Fine Arts" , "Auditory" , "Architecture" , "Jazz" , "Opera" , "Visual"
3045
3146 ]),
32- ("RMPSS" , ["Religion" , "Mythology" , "Social Science" , "Philosophy" ]),
47+ ("RMPSS" , ["Religion" , "Mythology" , "Social Science" , "Philosophy" , "Social Economics" , "Social Linguistics" , "Social Other" , "Social Psychology" , "Social Sociology" ]),
3348]
3449
3550def toID (s : str ) -> str :
@@ -129,23 +144,42 @@ def addQBJAndPacket(self, qbj: QBJ, packet: PacketJSON) -> None:
129144 qnIdx = rawTossup ["question_number" ] - 1 # 1-indexed
130145 if qnIdx >= len (packet ["tossups" ]):
131146 print (f"Warning: tossup number { qnIdx } not found in packet" )
147+ print ()
132148 continue
133149
134150 text = packet ["tossups" ][qnIdx ]["question" ]
135151 answer = packet ["tossups" ][qnIdx ]["answer" ]
136- category = packet ["tossups" ][qnIdx ]["metadata" ]
137- if "- " in category :
138- category = category .split ("- " )[1 ]
139- if " -" in category :
140- category = category .split (" -" )[1 ]
152+ category = packet ["tossups" ][qnIdx ]["metadata" ].strip ()
153+ if ", " in category :
154+ category = category .split (', ' )[1 ]
155+ category = category .replace ('Belief/Thought - ' , '' )
156+ category = category .replace ('Fine Arts - ' , '' )
157+ category = category .replace ('Science - ' , '' )
158+ category = category .replace ('Other - ' , '' )
159+ for preamble in ["History - " , "Literature - " , "Literature – " ]:
160+ if category .startswith (preamble ):
161+ category = category .replace (preamble , '' )
162+ category += " " + preamble .split (' ' )[0 ]
163+ if category .endswith ('Literature' ):
164+ category = category .split ('- ' )[0 ].strip () + " Literature"
165+ # if "- " in category:
166+ # category = category.split("- ")[1]
167+ # if " -" in category:
168+ # category = category.split(" -")[1]
141169 # slight hack because MS is annoying
170+ category = category .replace ("History History" , "History" )
171+ category = category .replace ("Literature Literature" , "Literature" )
142172 if category == "World Literature" :
143173 category = "World/Other Literature"
144174 if category == "Ancient History" :
145175 category = "Ancient/Other History"
146176 if category == "Geography/Current Events/Other" or category == "Current Events" :
147177 category = "Geography/Current Events/Other Academic"
148178
179+ for catP in ['Religion' , 'Mythology' ]:
180+ if category .startswith (catP + ' -' ):
181+ category = catP
182+
149183 self .categories .add (category )
150184
151185 # udpate tossups heard
@@ -159,6 +193,7 @@ def addQBJAndPacket(self, qbj: QBJ, packet: PacketJSON) -> None:
159193 playersWhoHeardIt = players
160194
161195 for p in playersWhoHeardIt :
196+ print (p )
162197 if p not in self .playerStatsByCategory :
163198 self .playerStatsByCategory [p ] = {}
164199 if category not in self .playerStatsByCategory [p ]:
@@ -275,13 +310,15 @@ def statsToHTML(self, name: str) -> str:
275310 <th>+15</th>
276311 <th>+10</th>
277312 <th>-5</th>
313+ <th>Aggression</th>
278314 <th>Average buzz position</th></thead>"""
279315 playerStats : List [Tuple [
280316 Player ,
281317 str , # PPTUH
282318 int , # Powers
283319 int , # gets
284320 int , # Negs
321+ str , # Aggression
285322 str , # avg buzz position
286323 ]] = []
287324 # hack
@@ -300,10 +337,13 @@ def statsToHTML(self, name: str) -> str:
300337 powers = cat .powers
301338 tens = cat .tens
302339 negs = cat .negs
340+ aggression = "n/a"
341+
303342 avgBuzzPosition = "n/a"
304343 if len (cat .buzzPositions ) > 0 :
305344 avgBuzzPosition = str (round (sum (cat .buzzPositions ) / len (cat .buzzPositions ), 2 ))
306- playerStats .append ((player , pptuh , powers , tens , negs , avgBuzzPosition ))
345+ aggression = str (round ((cat .powers + cat .negs )/ len (cat .buzzPositions ), 3 ))
346+ playerStats .append ((player , pptuh , powers , tens , negs , aggression , avgBuzzPosition ))
307347 # sort by PPG initially
308348 playerStats .sort (key = lambda x : float (x [1 ]), reverse = True )
309349 if len (playerStats ) == 0 :
@@ -317,6 +357,7 @@ def statsToHTML(self, name: str) -> str:
317357 <td>{ stat [3 ]} </td>
318358 <td>{ stat [4 ]} </td>
319359 <td>{ stat [5 ]} </td>
360+ <td>{ stat [6 ]} </td>
320361 </tr>"""
321362 curHTML += "</table>"
322363
@@ -339,6 +380,7 @@ def statsToHTML(self, name: str) -> str:
339380 <th>+15</th>
340381 <th>+10</th>
341382 <th>-5</th>
383+ <th>Aggression</th>
342384 <th>Average buzz position</th></thead>"""
343385 categoryStats : List [Tuple [
344386 Category ,
@@ -361,13 +403,17 @@ def statsToHTML(self, name: str) -> str:
361403
362404 ppg = "0"
363405 if cat .tossupsHeard != 0 :
406+ # print(f"{player} in {category}: {cat.points} pts in {cat.tossupsHeard} TUs")
364407 ppg = str (round ((cat .points / cat .tossupsHeard )* 20 , 2 ))
365408 powers = cat .powers
366409 negs = cat .negs
367410 avgBuzzPosition = "n/a"
411+ aggression = "n/a"
368412 if len (cat .buzzPositions ) > 0 :
369413 avgBuzzPosition = str (round (sum (cat .buzzPositions ) / len (cat .buzzPositions ), 2 ))
370- categoryStats .append ((category , ppg , powers , cat .tens , negs , avgBuzzPosition ))
414+ aggression = str (round ((cat .powers + cat .negs )/ len (cat .buzzPositions ), 3 ))
415+
416+ categoryStats .append ((category , ppg , powers , cat .tens , negs , aggression , avgBuzzPosition ))
371417 # sort by PPG initially
372418 categoryStats .sort (key = lambda x : float (x [1 ]), reverse = True )
373419
@@ -379,6 +425,7 @@ def statsToHTML(self, name: str) -> str:
379425 <td>{ stat [3 ]} </td>
380426 <td>{ stat [4 ]} </td>
381427 <td>{ stat [5 ]} </td>
428+ <td>{ stat [6 ]} </td>
382429 </tr>"""
383430 html += "</table>"
384431
0 commit comments