Repository navigation
fix(english): add missing "ninth" ordinal to the number normalizer - #38
Open
selimfedakar wants to merge 1 commit into
Open
selimfedakar wants to merge 1 commit into
selimfedakar wants to merge 1 commit into
Conversation
The ordinal table generated keys with a generic "<word>th" rule, which produces "nineth" for "nine" (the 'e' should drop). As a result the real ordinal "ninth" had no entry and was left unconverted: "twenty ninth" normalized to "20 ninth" instead of "29th". Hand-code "ninth" alongside the other irregular ordinals (first/second/third/fifth/twelfth) and exclude 9 from the generic rule. Add unit and gladia-3 pipeline regression tests.
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.
Problem
EnglishNumberNormalizerbuilds its ordinal table by hand-coding the irregular forms (first,second,third,fifth,twelfth) and generating the rest with a generic rule:For
"nine"that rule produces the key"nineth"— but the real English ordinal is"ninth"(theedrops). So the table ends up with a bogus"nineth"entry and no"ninth", and real"ninth"input is left unconverted:"nine"is the only single-word ordinal whose stem changes irregularly and is not already hand-coded, so it's the only one affected (tenth,fifth,eighth, … are fine).Fix
Hand-code
"ninth"alongside the other irregular ordinals and exclude9from the generic rule.Verification
302 passedfor the English number-normalizer suite (no regressions). Added regression tests:test_ninth_ordinal_normalizes— standalone normalizer:"ninth" -> "9th","twenty ninth" -> "29th".test_ninth_ordinal_through_gladia_3_pipeline— parametrized throughload_pipeline("gladia-3", "en"):ninth,twenty ninth,one hundred ninth.Both fail on
mainand pass with the fix.Note
This module is derived from OpenAI Whisper's
EnglishNumberNormalizer, and the sameninethtypo exists upstream — so it is a faithfully-inherited upstream bug rather than one introduced here, but it is a genuine, reproducible defect in this module with a safe, local fix. Happy to adjust framing if you'd prefer to track it against upstream.