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

Function _fix_fracs

data_preprocessing/math_util/math_normalize.py:24–53  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

22
23
24def _fix_fracs(string):
25 substrs = string.split("\\frac")
26 new_str = substrs[0]
27 if len(substrs) > 1:
28 substrs = substrs[1:]
29 for substr in substrs:
30 new_str += "\\frac"
31 if substr[0] == "{":
32 new_str += substr
33 else:
34 try:
35 assert len(substr) >= 2
36 except:
37 return string
38 a = substr[0]
39 b = substr[1]
40 if b != "{":
41 if len(substr) > 2:
42 post_substr = substr[2:]
43 new_str += "{" + a + "}{" + b + "}" + post_substr
44 else:
45 new_str += "{" + a + "}{" + b + "}"
46 else:
47 if len(substr) > 2:
48 post_substr = substr[2:]
49 new_str += "{" + a + "}" + b + post_substr
50 else:
51 new_str += "{" + a + "}" + b
52 string = new_str
53 return string
54
55
56def _fix_a_slash_b(string):

Callers 1

_strip_stringFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected