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

Function normalize_answer

data_preprocessing/math_util/math_normalize.py:10–21  ·  view source on GitHub ↗
(answer: Optional[str])

Source from the content-addressed store, hash-verified

8
9
10def normalize_answer(answer: Optional[str]) -> Optional[str]:
11 if answer is None:
12 return None
13 answer = answer.strip()
14 try:
15 # Remove enclosing `\text{}`.
16 m = re.search("^\\\\text\{(?P<text>.+?)\}$", answer)
17 if m is not None:
18 answer = m.group("text").strip()
19 return _strip_string(answer)
20 except:
21 return answer
22
23
24def _fix_fracs(string):

Callers

nothing calls this directly

Calls 2

_strip_stringFunction · 0.70
groupMethod · 0.45

Tested by

no test coverage detected