MCPcopy Create free account
hub / github.com/InternScience/SciReason / extract_boxed_answer

Function extract_boxed_answer

opencompass/datasets/math.py:54–65  ·  view source on GitHub ↗
(pred_str, strip_double_curly_brace=False)

Source from the content-addressed store, hash-verified

52
53
54def extract_boxed_answer(pred_str, strip_double_curly_brace=False):
55 boxed_str = last_boxed_only_string(pred_str)
56 if boxed_str is None:
57 return None
58 answer = remove_boxed(boxed_str)
59 if answer is None:
60 return None
61 if strip_double_curly_brace:
62 match = re.match('^\{(.*)\}$', answer) # noqa: W605
63 if match:
64 answer = match.group(1)
65 return answer
66
67
68def normalize_final_answer(final_answer: str) -> str:

Callers 2

loadMethod · 0.70
math_postprocess_v2Function · 0.70

Calls 3

groupMethod · 0.80
last_boxed_only_stringFunction · 0.70
remove_boxedFunction · 0.70

Tested by

no test coverage detected