MCPcopy Create free account
hub / github.com/InternScience/SciReason / last_boxed_only_string

Function last_boxed_only_string

opencompass/datasets/math.py:16–41  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

14
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 is None:
37 retval = None
38 else:
39 retval = string[idx:right_brace_idx + 1]
40
41 return retval
42
43
44def remove_boxed(s):

Callers 1

extract_boxed_answerFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected