Support plain mixed-number extraction - #81
Open
dkajtoch wants to merge 3 commits into
Open
Conversation
Author
|
@hynky1999, would you mind reviewing this change? It adds plain mixed-number extraction and prevents finite-fragment false positives such as |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
math_verify.parse()does not recognize plain mixed-number notation such as11 5/6as one value. The generic expression and number patterns can instead expose finite fragments of the answer as independent candidates.This causes more than a missed equivalence with
71/6: it can produce false positives. For example,2 2/3can expose2and incorrectly match a gold answer of2. Invalid mixed-looking syntax has the same problem:4 10/3can expose10and incorrectly match a gold answer of10instead of being rejected.Solution
This PR adds a higher-priority mixed-number extraction path before the generic expression and number patterns.
Consequently,
11 5/6is interpreted as11 + 5/6, while4 10/3is rejected. The explicit expression4 + 10/3remains valid.Checks run
.venv/bin/pytest -q tests/test_mixed_number_extraction.py: 42 passed.venv/bin/pytest -q: 332 passed, 1 failed; the remaining LaTeX-percentage failure is unchanged onupstream/main.venv/bin/ruff check tests/test_mixed_number_extraction.py: passed.venv/bin/ruff format --check src/math_verify/parser.py tests/test_mixed_number_extraction.py: passeduv build: source distribution and wheel built successfullyThe existing
parser.pyimport-order and unused-import Ruff findings are also present onupstream/mainand are outside this change.