Repository navigation
Fix English number normalizer: 'ninth' never normalized (generated 'nineth') - #2897
Open
PratikDhanave wants to merge 1 commit into
Open
PratikDhanave wants to merge 1 commit into
PratikDhanave wants to merge 1 commit into
Conversation
…ineth') EnglishNumberNormalizer.ones_ordinal is built by appending 'th' to each cardinal (special-casing only words ending in 't', e.g. eight -> eighth). 'nine' does not end in 't', so the generated key is the non-word 'nineth', and the real ordinal 'ninth' is absent from the map. As a result 'ninth' is left un-normalized and any compound ordinal ending in nine is broken: 'ninth' -> 'ninth' (expected '9th') 'twenty ninth' -> '20 ninth' (expected '29th') 'ninety ninth' -> '90 ninth' (expected '99th') 'one hundred ninth'-> '100 ninth' (expected '109th') Special-case 'ninth' explicitly (like first/second/third/fifth/twelfth) and exclude 9 from the generated set. Add ordinal regression assertions.
koksalenes
reviewed
Nov 4, 2026
koksalenes
left a comment
There was a problem hiding this comment.
Correctly handles ordinal numbers and plural forms now
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.
Summary
The English number normalizer never normalizes the ordinal "ninth", and breaks every compound ordinal ending in nine.
Problem
EnglishNumberNormalizer.ones_ordinal(whisper/normalizers/english.py) is generated by appending"th"to each cardinal, special-casing only words ending in"t":"nine"does not end in"t", so this produces the non-word key"nineth". The real ordinal"ninth"is therefore absent from the map, so it is left un-normalized:ninthninth9ththe ninth of maythe ninth of maythe 9th of maytwenty ninth20 ninth29thninety ninth90 ninth99thone hundred ninth100 ninth109th(
"nineth"— a string that never appears in real text — is present in the map, which confirms the generator simply targeted the wrong key.)Fix
Special-case
"ninth"explicitly, exactly like the other irregular ordinals (first/second/third/fifth/twelfth), and exclude9from the generated set:Validation
Added ordinal assertions to
tests/test_normalizer.py(ninth,twenty ninth,ninety ninth,one hundred ninth).assert std("ninth") == "9th"fails ('ninth' != '9th').tests/test_normalizer.pypasses (4 passed) with the change; the existing suite had no ordinal-ending-in-nine coverage, which is why this shipped.Developed with AI assistance: the bug was located, the fix applied, and tests written and run locally (pytest). I have reviewed and verified the change and take responsibility for it.