Repository navigation
Read numbers grouped with no-break, narrow no-break or thin spaces - #1478
Open
ChrystianSchutz wants to merge 1 commit into
Open
ChrystianSchutz wants to merge 1 commit into
ChrystianSchutz wants to merge 1 commit into
Conversation
Format 1 of number_re joined digit groups only with an ASCII space or a comma, so a number written with U+202F between groups was read as only one of its groups. Fixes huggingface#1476 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Fixes #1476
Format 1 of
number_rejoined digit groups only with an ASCII space or a comma. Numbers typeset with U+00A0 (no-break space), U+202F (narrow no-break space) or U+2009 (thin space) were split in two:ANSWER: 2\u202f500was read as 2, andThe total is 2\u2009500.as 500. Bothmath_scorer()andMultilingualExtractiveMatchMetricwere affected.This PR does two things:
extract_expr.(?!\d)after the last group, so a run of four or more digits is no longer cut:ANSWER: 7 1234was 7123 and is now 7. As a side effect,1,2345now reads as 1.2345 through the decimal-comma format, the same way3,14already does; before, it was 1234 with a digit dropped.Tests:
tests/unit/metrics/test_extractive_match.py: the three spaces, a decimal part, several groups, and controls for an ASCII space, a 4-digit group and a space before a word. 9 of the 12 fail onmainand all 12 pass with the change.test_extractive_match.py+test_normalizations.py: 249 passed.ruff checkandruff format --checkare clean.The patch file stays ASCII: the code points are written as
\uescapes.Prepared with AI assistance (Claude). The tests above were run in a clean environment at b97a653.
🤖 Generated with Claude Code