math.py 355 Bytes
Newer Older
chenych's avatar
chenych committed
1
2
3
4
5
6
7
8
9
10
11
12
from mathruler.grader import extract_boxed_content, grade_answer


def math_compute_score(predict_str: str, ground_truth: str) -> float:
    answer = extract_boxed_content(predict_str)
    if answer == "None":
        return 0.0  # no answer

    if grade_answer(answer, ground_truth):
        return 1.0  # correct answer

    return 0.1  # wrong answer