Repository navigation
Fix Swedish number normalizer dropping unit ett after a hundreds-block - #47
Open
selimfedakar wants to merge 1 commit into
Open
selimfedakar wants to merge 1 commit into
selimfedakar wants to merge 1 commit into
Conversation
_parse_0_99 returns None for a standalone 'en'/'ett', so a hundreds-block with unit-one remainder returned early and the following 'tusen' never attached: 'hundra ett tusen' normalized to '100 1000' instead of '101000'. Add _parse_0_99_after_hundred (mirroring the Danish sibling, which is reference-correct) to accept 'en'/'ett' as unit 1 only in the unambiguous hundreds-remainder position. Adds a focused test.
This branch has not been deployed
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
Fix a dropped thousands multiplier in the Swedish number normalizer (
normalization/languages/swedish/number_normalizer.py), the same class as the recently-fixed Spanishmilbug (#46).When a hundreds-block is followed by the unit one (
en/ett) as its remainder before a multiplier, the remainder is dropped:_parse_0_99returnsNonefor a standaloneen/ett, so the hundreds block returns early (just100/300), the followingtusennever attaches, and the number splits apart —"hundra ett tusen"(101000) becomes"100 1000".The Danish sibling is reference-correct here (it already added an equivalent
_parse_0_99_after_oghelper producing101000), confirming this is a Swedish gap, not intended behavior.Fix
Add
_parse_0_99_after_hundred(mirroring Danish): parse 0–99 normally, and if that fails, accept a standaloneen/ettas unit 1 — but only in the hundreds-remainder position, where it is grammatically unambiguous. Both hundreds branches call it. A phrase-initial bareettstays a word (soen kronais untouched).Before / after (public API)
hundra ett tusen100 1000101000tre hundra ett tusen fem300 1005301005Non-regression:
en krona→en krona,ett tusen→1000,tjugo tusen fem→20005,två hundra femtio tusen→250000.Reachability / tests
SwedishNumberNormalizer.__call__←SwedishOperators.expand_written_numbers← pipeline. Adds a focused test (test_unit_one_after_hundred_keeps_grouping) that fails onmainand passes with this change; full unit suite stays green.Note: the Norwegian and Finnish normalizers appear to share the identical gap — happy to follow up with those (here or in a combined PR) if you prefer.