MCPcopy
hub / github.com/deepseek-ai/DeepSeek-Coder / _fix_fracs

Function _fix_fracs

Evaluation/PAL-Math/utils/parser.py:8–37  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

6
7
8def _fix_fracs(string):
9 substrs = string.split("\\frac")
10 new_str = substrs[0]
11 if len(substrs) > 1:
12 substrs = substrs[1:]
13 for substr in substrs:
14 new_str += "\\frac"
15 if len(substr) > 0 and substr[0] == "{":
16 new_str += substr
17 else:
18 try:
19 assert len(substr) >= 2
20 except:
21 return string
22 a = substr[0]
23 b = substr[1]
24 if b != "{":
25 if len(substr) > 2:
26 post_substr = substr[2:]
27 new_str += "{" + a + "}{" + b + "}" + post_substr
28 else:
29 new_str += "{" + a + "}{" + b + "}"
30 else:
31 if len(substr) > 2:
32 post_substr = substr[2:]
33 new_str += "{" + a + "}" + b + post_substr
34 else:
35 new_str += "{" + a + "}" + b
36 string = new_str
37 return string
38
39
40def _fix_a_slash_b(string):

Callers 1

strip_stringFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected