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

Function last_boxed_only_string

opencompass/datasets/math_intern.py:13–38  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

11
12
13def last_boxed_only_string(string):
14 idx = string.rfind('\\boxed')
15 if idx < 0:
16 idx = string.rfind('\\fbox')
17 if idx < 0:
18 return None
19
20 i = idx
21 right_brace_idx = None
22 num_left_braces_open = 0
23 while i < len(string):
24 if string[i] == '{':
25 num_left_braces_open += 1
26 if string[i] == '}':
27 num_left_braces_open -= 1
28 if num_left_braces_open == 0:
29 right_brace_idx = i
30 break
31 i += 1
32
33 if right_brace_idx is None:
34 retval = None
35 else:
36 retval = string[idx:right_brace_idx + 1]
37
38 return retval
39
40
41def remove_boxed(s):

Callers 1

extract_boxed_answerFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected