r"""Extract all \boxed{...} contents, handling nested braces.
(text: str)
| 38 | |
| 39 | |
| 40 | def _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 | |
| 64 | def _normalize_ground_truth(ground_truth: str) -> str: |
no outgoing calls
no test coverage detected