MCPcopy Create free account
hub / github.com/ScaleML/AgentSPEX / _extract_boxed

Function _extract_boxed

src/benchmarks/aime/evaluate.py:40–61  ·  view source on GitHub ↗

r"""Extract all \boxed{...} contents, handling nested braces.

(text: str)

Source from the content-addressed store, hash-verified

38
39
40def _extract_boxed(text: str) -> list[str]:
41 r"""Extract all \boxed{...} contents, handling nested braces."""
42 results = []
43 prefix = r"\boxed{"
44 i = 0
45 while i < len(text):
46 idx = text.find(prefix, i)
47 if idx == -1:
48 break
49 start = idx + len(prefix)
50 depth = 1
51 j = start
52 while j < len(text) and depth > 0:
53 if text[j] == "{":
54 depth += 1
55 elif text[j] == "}":
56 depth -= 1
57 j += 1
58 if depth == 0:
59 results.append(text[start : j - 1])
60 i = j
61 return results
62
63
64def _normalize_ground_truth(ground_truth: str) -> str:

Callers 2

parse_answerFunction · 0.85
verify_answerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected