MCPcopy Create free account
hub / github.com/OpenBitSys/BitDistiller / fix_fracs

Method fix_fracs

test/general/lm_eval/tasks/hendrycks_math.py:147–176  ·  view source on GitHub ↗
(self, string)

Source from the content-addressed store, hash-verified

145 return retval
146
147 def fix_fracs(self, string):
148 substrs = string.split("\\frac")
149 new_str = substrs[0]
150 if len(substrs) > 1:
151 substrs = substrs[1:]
152 for substr in substrs:
153 new_str += "\\frac"
154 if substr[0] == "{":
155 new_str += substr
156 else:
157 try:
158 assert len(substr) >= 2
159 except AssertionError:
160 return string
161 a = substr[0]
162 b = substr[1]
163 if b != "{":
164 if len(substr) > 2:
165 post_substr = substr[2:]
166 new_str += "{" + a + "}{" + b + "}" + post_substr
167 else:
168 new_str += "{" + a + "}{" + b + "}"
169 else:
170 if len(substr) > 2:
171 post_substr = substr[2:]
172 new_str += "{" + a + "}" + b + post_substr
173 else:
174 new_str += "{" + a + "}" + b
175 string = new_str
176 return string
177
178 def fix_a_slash_b(self, string):
179 if len(string.split("/")) != 2:

Callers 1

strip_stringMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected