Spaces:
Sleeping
Sleeping
Download app_logic.py from justhariharan/Math-Solver: direct link, hf CLI and curl.
- Browser
- Download file 401 Bytes
-
https://huggingface.co/spaces/justhariharan/Math-Solver/resolve/main/app_logic.py
- Command line
-
hf download hf://spaces/justhariharan/Math-Solver/app_logic.py
-
curl -L -o app_logic.py https://huggingface.co/spaces/justhariharan/Math-Solver/resolve/main/app_logic.py
401 Bytes
| import re | |
| def extract_answer(text): | |
| """Return only an explicitly marked final answer, never a number from reasoning.""" | |
| if not text or "####" not in text: | |
| return None | |
| final = text.rsplit("####", 1)[-1].strip() | |
| match = re.search(r"(?<![A-Za-z0-9])(-?\$?\d[\d,]*(?:\.\d+)?)(?![A-Za-z0-9])", final) | |
| return match.group(1).replace(",", "").replace("$", "") if match else None | |