MCPcopy Create free account
hub / github.com/Alpha-VLLM/LLaMA2-Accessory / fix_fracs

Function fix_fracs

light-eval/src/eval_utils/math_util.py:94–123  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

92 return new_string
93
94def fix_fracs(string):
95 substrs = string.split("\\frac")
96 new_str = substrs[0]
97 if len(substrs) > 1:
98 substrs = substrs[1:]
99 for substr in substrs:
100 new_str += "\\frac"
101 if substr[0] == "{":
102 new_str += substr
103 else:
104 try:
105 assert len(substr) >= 2
106 except AssertionError:
107 return string
108 a = substr[0]
109 b = substr[1]
110 if b != "{":
111 if len(substr) > 2:
112 post_substr = substr[2:]
113 new_str += "{" + a + "}{" + b + "}" + post_substr
114 else:
115 new_str += "{" + a + "}{" + b + "}"
116 else:
117 if len(substr) > 2:
118 post_substr = substr[2:]
119 new_str += "{" + a + "}" + b + post_substr
120 else:
121 new_str += "{" + a + "}" + b
122 string = new_str
123 return string
124
125def fix_a_slash_b(string):
126 if len(string.split("/")) != 2:

Callers 1

strip_stringFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected