MasteredUltraInstinct commited on
Commit
95df718
·
verified ·
1 Parent(s): 0af2125

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -0
app.py CHANGED
@@ -19,13 +19,27 @@ model = LatexOCR()
19
 
20
  # Clean LaTeX output
21
  def clean_latex(latex):
 
22
  latex = re.sub(r'\\(cal|mathcal)\s*X', 'x', latex)
 
 
23
  latex = latex.replace('{', '').replace('}', '')
24
  latex = latex.strip().rstrip(',.')
 
 
 
 
 
 
 
 
 
25
  if '=' not in latex:
26
  latex += '=0'
 
27
  return latex
28
 
 
29
  # Main function
30
  def solve_polynomial(image):
31
  try:
 
19
 
20
  # Clean LaTeX output
21
  def clean_latex(latex):
22
+ # Replace mathcal X with x
23
  latex = re.sub(r'\\(cal|mathcal)\s*X', 'x', latex)
24
+
25
+ # Remove unwanted characters
26
  latex = latex.replace('{', '').replace('}', '')
27
  latex = latex.strip().rstrip(',.')
28
+
29
+ # Replace \pi and the Unicode character π with 3.1416
30
+ latex = latex.replace(r'\pi', '3.1416')
31
+ latex = latex.replace('π', '3.1416')
32
+
33
+ # Replace standalone 'e' with 2.7183 (not part of other variable names)
34
+ latex = re.sub(r'(?<![a-zA-Z0-9])e(?![a-zA-Z0-9])', '2.7183', latex)
35
+
36
+ # Append =0 if not present
37
  if '=' not in latex:
38
  latex += '=0'
39
+
40
  return latex
41
 
42
+
43
  # Main function
44
  def solve_polynomial(image):
45
  try: