in src/latex2sympy2_extended/math_normalization.py [0:0]
def _fix_a_slash_b(text: str) -> str:
"""Source: https://github.com/hendrycks/math
Reformat fractions formatted as a/b to \\frac{a}{b}.
Example:
>>> _fix_a_slash_b("2/3")
\frac{2}{3}
"""
if len(text.split("/")) != 2:
return text
a_str = text.split("/")[0]
b_str = text.split("/")[1]
try:
a = int(a_str)
b = int(b_str)
assert text == "{}/{}".format(a, b)
new_string = "\\frac{" + str(a) + "}{" + str(b) + "}"
return new_string
except Exception:
return text