diff --git a/ml-model/mathpix/ml-benchmarking/test_parselatex.py b/ml-model/mathpix/ml-benchmarking/test_parselatex.py index f74a7d9b3..c2cf790a3 100644 --- a/ml-model/mathpix/ml-benchmarking/test_parselatex.py +++ b/ml-model/mathpix/ml-benchmarking/test_parselatex.py @@ -4,6 +4,8 @@ from zss import Node, distance import sympy as sp from sympy.parsing.latex import parse_latex +from sympy.parsing.sympy_parser import (standard_transformations, + implicit_multiplication_application) def preprocess_latex(latex_src, rem): @@ -50,11 +52,14 @@ def sympy_to_zss(expr): node.addkid(child_node) return node + # Input is string of LaTeX source code. Runs sympy parser and ZSS tree parser. # Returns parsed ZSS tree. def source_to_zss(latex_expr): sympy_expr = parse_latex(latex_expr) + print(sympy_expr) zss_tree = sympy_to_zss(sympy_expr) + print(zss_tree) return zss_tree def show_image(image): @@ -69,9 +74,6 @@ def show_image(image): # print(df['latex_formula'][0]) # string print() -print(df['latex_formula'][0]) -print(source_to_zss(df['latex_formula'][0])) -print() -print(df['latex_formula'][1]) -print(source_to_zss(df['latex_formula'][1])) +print("First:") +source_to_zss(r"\frac{1}{2} = 2") print() \ No newline at end of file