Repository navigation
fix(parser): extract scientific notation exponents in ExprExtractionConfig - #89
Open
Virtuoso461 wants to merge 1 commit into
Open
Virtuoso461 wants to merge 1 commit into
Virtuoso461 wants to merge 1 commit into
Conversation
…onfig
The expr number regex stopped right after the mantissa, so "1.5e3" was
extracted as 1.5 and "6.02e23" as 6.02. Answers written in scientific
notation were then compared against the mantissa alone, e.g.
verify('The answer is 1.5e3.', 'The answer is 1500.') returned False.
Adds an optional (?P<exponent>[eE][-+]?\d+) group to number_re and
appends it when building the number string. A trailing e without digits
still does not count as an exponent ('word1e' extracts nothing).
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.
What does this PR do?
ExprExtractionConfigparsing dropped scientific-notation exponents: the number regex stopped right after the mantissa, so"1.5e3"was extracted as1.5and"6.02e23"as6.02. Answers written in scientific notation were compared against the mantissa alone:Fix
Adds an optional
(?P<exponent>[eE][-+]?\d+)group after the integer/decimal alternation innumber_re, and appends it when building the number string inextract_expr. Sympy'sNumber("1.5e3")then evaluates to 1500.A trailing
ewithout digits still does not count as an exponent —word1eextracts nothing, as before.Tests
New
tests/test_scientific_notation.py:1.5e3verifies equal to1500eFull suite (excluding large corpus files): 241 passed, no regressions. On the unpatched tree the new tests fail 5/6.