MCPcopy Create free account
hub / github.com/PRIME-RL/PRIME / compare_ans

Function compare_ans

eval/Math/Qwen25-Math/evaluation/math_utils.py:210–233  ·  view source on GitHub ↗
(ans_p_str, ans_l_str, is_strict=False)

Source from the content-addressed store, hash-verified

208
209@timeout_decorator.timeout(5)
210def compare_ans(ans_p_str, ans_l_str, is_strict=False):
211 ans_p_str = clean_expr_str(ans_p_str)
212 ans_p_str = ans_p_str.replace(",", "").replace("$", "")
213 ans_l_str = clean_expr_str(ans_l_str)
214 ans_l_str = ans_l_str.replace(",", "").replace("$", "")
215 if ans_p_str is None:
216 return False
217 if ans_p_str.replace(" ", "") == ans_l_str.replace(" ", ""):
218 return True
219 ans_p = parse_latex_answer(ans_p_str)
220 if ans_p is None:
221 return False
222 ans_l = parse_latex_answer(ans_l_str)
223 if ans_l is None:
224 return False
225 if is_expr_equal(ans_p, ans_l, is_strict=is_strict):
226 return True
227 # TODO not suitable
228 ans_p_str = extract_answer_number(ans_p_str)
229 if is_number(ans_p_str):
230 ans_p = parse_latex_answer(ans_p_str)
231 if is_expr_equal(ans_p, ans_l, is_strict=is_strict):
232 return True
233 return False
234
235
236def vote(answers):

Callers 1

math_utils.pyFile · 0.85

Calls 5

clean_expr_strFunction · 0.85
parse_latex_answerFunction · 0.85
is_expr_equalFunction · 0.85
extract_answer_numberFunction · 0.85
is_numberFunction · 0.85

Tested by

no test coverage detected