MCPcopy
hub / github.com/BytedTsinghua-SIA/DAPO / last_boxed_only_string

Function last_boxed_only_string

eval/math_dapo.py:21–48  ·  view source on GitHub ↗

Extract the last LaTeX boxed expression from a string. Args: string: Input string containing LaTeX code Returns: The last boxed expression or None if not found

(string: str)

Source from the content-addressed store, hash-verified

19
20
21def last_boxed_only_string(string: str) -> Optional[str]:
22 """Extract the last LaTeX boxed expression from a string.
23
24 Args:
25 string: Input string containing LaTeX code
26
27 Returns:
28 The last boxed expression or None if not found
29 """
30 idx = string.rfind("\\boxed{")
31 if idx < 0:
32 return None
33
34 i = idx
35 right_brace_idx = None
36 num_left_braces_open = 0
37
38 while i < len(string):
39 if string[i] == "{":
40 num_left_braces_open += 1
41 if string[i] == "}":
42 num_left_braces_open -= 1
43 if num_left_braces_open == 0:
44 right_brace_idx = i
45 break
46 i += 1
47
48 return string[idx:right_brace_idx + 1] if right_brace_idx is not None else None
49
50
51def remove_boxed(s: str) -> str:

Callers 2

is_correct_minervaFunction · 0.85
is_correct_strict_boxFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected