dotandru commited on
Commit
721b0c4
·
1 Parent(s): a162bd1

V9.0.3: CRITICAL Hotfixes - Anchor Validator NameError & SymPy LaTeX Multiplication Support

Browse files
Files changed (2) hide show
  1. domain/math_validator.py +5 -1
  2. utils/math_utils.py +4 -0
domain/math_validator.py CHANGED
@@ -17,7 +17,7 @@ _HEBREW_ONLY = re.compile(r'^[\u0590-\u05FF\s]+$')
17
 
18
  # LaTeX commands that SymPy cannot parse — strip layout but KEEP math functions
19
  _LATEX_STRIP = re.compile(
20
- r'\\(?:left|right|cdot|times|div|pm|mp|leq|geq|neq'
21
  r'|approx|infty|text|mathrm|mathbf|boxed|underbrace|overbrace|hat|bar|vec|dot|overline|underline)\b'
22
  )
23
 
@@ -52,6 +52,10 @@ def _latex_to_sympy_str(latex_str: str) -> str:
52
  s = s.replace(r'\tan', ' tan ').replace(r'\sqrt', ' sqrt ').replace(r'\log', ' log ')
53
  s = s.replace(r'\exp', ' exp ').replace(r'\pi', ' pi ').replace(r'\theta', ' theta ')
54
 
 
 
 
 
55
  # 3. Remove remaining purely structural LaTeX commands
56
  s = _LATEX_STRIP.sub(' ', s)
57
 
 
17
 
18
  # LaTeX commands that SymPy cannot parse — strip layout but KEEP math functions
19
  _LATEX_STRIP = re.compile(
20
+ r'\\(?:left|right|div|pm|mp|leq|geq|neq'
21
  r'|approx|infty|text|mathrm|mathbf|boxed|underbrace|overbrace|hat|bar|vec|dot|overline|underline)\b'
22
  )
23
 
 
52
  s = s.replace(r'\tan', ' tan ').replace(r'\sqrt', ' sqrt ').replace(r'\log', ' log ')
53
  s = s.replace(r'\exp', ' exp ').replace(r'\pi', ' pi ').replace(r'\theta', ' theta ')
54
 
55
+ # --- 🚀 BEGIN HOTFIX V9.0.3: LATEX MULTIPLICATION ---
56
+ s = s.replace(r'\cdot', '*').replace(r'\times', '*')
57
+ # --- END HOTFIX ---
58
+
59
  # 3. Remove remaining purely structural LaTeX commands
60
  s = _LATEX_STRIP.sub(' ', s)
61
 
utils/math_utils.py CHANGED
@@ -47,6 +47,10 @@ def aggressive_sympy_sanitizer(latex_str: str) -> List[str]:
47
  arrows = [r'\Rightarrow', r'\implies', r'\iff', r'\rightarrow']
48
  for arrow in arrows:
49
  s = s.replace(arrow, '=')
 
 
 
 
50
 
51
  # 4. Split multiple equations
52
  # SymPy cannot parse "x=0, y=9" as a single AST node.
 
47
  arrows = [r'\Rightarrow', r'\implies', r'\iff', r'\rightarrow']
48
  for arrow in arrows:
49
  s = s.replace(arrow, '=')
50
+
51
+ # --- 🚀 BEGIN HOTFIX V9.0.3: LATEX MULTIPLICATION ---
52
+ s = s.replace(r'\cdot', '*').replace(r'\times', '*')
53
+ # --- END HOTFIX ---
54
 
55
  # 4. Split multiple equations
56
  # SymPy cannot parse "x=0, y=9" as a single AST node.