Datasets:
File size: 877 Bytes
7f9a652 | 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 | """score.py with one guard: a gold/prediction pair that makes score.py raise
(e.g. string gold '111.242.222' vs a numeric prediction -> ValueError in
float(gold)) is counted as wrong instead of crashing. Everything else, including
the score.json format, is score.py unchanged. Same arguments as score.py.
Used by run_baselines.sh only as a fallback when score.py itself crashes.
"""
import os, sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import score # noqa: E402
_correct = score.correct
def guarded(item, pred, lenient=False):
try:
return _correct(item, pred, lenient)
except (ValueError, TypeError):
print(f"score_guarded: {item['id']}: score.py raised on pred {pred!r}; counted wrong", file=sys.stderr)
return False
score.correct = guarded
if __name__ == '__main__':
score.main()
|