# Rescore E17 output with both graders. Expected: 500 rows, v1 380, v2 396, 0 answers accepted by v1 but rejected by v2.
# Usage: python e17_rescore.py e17_math500_greedy.jsonl   (math_grade.py and math_grade_v2.py in the same folder)
import json, sys
import math_grade as g1, math_grade_v2 as g2
R = [json.loads(l) for l in open(sys.argv[1], encoding="utf-8")]
v1 = sum(g1.correct(r["text"], r["gold"]) for r in R); v2 = sum(g2.correct(r["text"], r["gold"]) for r in R)
print(len(R), "rows; grader v1", v1, "; grader v2", v2, "; v1-only", sum(g1.correct(r["text"], r["gold"]) and not g2.correct(r["text"], r["gold"]) for r in R))
