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

Function last_boxed_only_string

eval/utils/util.py:16–41  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

14 return (q, a)
15
16def last_boxed_only_string(string):
17 idx = string.rfind("\\boxed")
18 if idx < 0:
19 idx = string.rfind("\\fbox")
20 if idx < 0:
21 return None
22
23 i = idx
24 right_brace_idx = None
25 num_left_braces_open = 0
26 while i < len(string):
27 if string[i] == "{":
28 num_left_braces_open += 1
29 if string[i] == "}":
30 num_left_braces_open -= 1
31 if num_left_braces_open == 0:
32 right_brace_idx = i
33 break
34 i += 1
35
36 if right_brace_idx == None:
37 retval = None
38 else:
39 retval = string[idx:right_brace_idx + 1]
40
41 return retval
42
43def only_until_first_boxed_from_tokens(string, tokens):
44 idx = string.find("\\boxed")

Callers 1

last_boxed_onlyFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected