Repository navigation
fix: a written number is read across punctuation and next to another one - #43
Merged
Merged
Conversation
The English expansion stopped at the first punctuation mark and read only one of two
adjacent written numbers, so "that is fifty." kept "fifty" and "sixty, seventy" became
"60 seventy". words2num2's sentence mode reads both, and it reads transcripts: "no one"
stays, a phone number stays a phone number.
It runs on this class's output, not instead of it, because the class reads forms
words2num2 does not ("20 thirteen" -> 2013, "25 hundred" -> 2500) and those keep their
value. It only runs when a written number is left, so a version or an address is not read
as a decimal ("2 dot 5 dot 1" stays, instead of "2 dot 50 point 1"). A lone "one" is left
alone too: it is a pronoun as often as a number.
num2words2 comes with words2num2 as its inverse and is what the new test writes the
numbers with: every number from 0 to 120, plus 999, 1234 and 10000, read back as its
digits through the published preset.
Fixes #42
egenthon-cmd
approved these changes
Nov 11, 2026
Conflicts: tests/e2e/files/gladia-3/en.csv — both sides append rows at the end of the file (this branch: a written number across punctuation; main: nonfiction / non-fiction from #41). Kept both.
2 tasks done
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?
Reads a written number across punctuation and beside another written number, using
words2num2's sentence mode after the existing English expansion.Type of change
Edit existing language
replacements.py, not inline inoperators.py— no substitution added hereNone: the step reading it still handlesNonegracefully — no config field changedWhy
Two rows of the pipecat STT benchmark were scored as engine errors only because the expansion stopped early:
EnglishNumberNormalizerwalks words one by one and stops at the first punctuation mark, and it consumes a single number out of two side by side.words2num2'swords2num_sentenceis built for transcripts and reads both, so it runs on the class's output.It runs after, not instead, because the class reads forms
words2num2does not and those keep their value:Those are the mixed digit-and-word forms ASR writes, and the two packages' repositories are archived, so they will not grow them: the class stays the place that reads them, and
words2num_sentenceis only the second pass. The order cannot be swapped — running it first leaves "20 thirteen" as "20 13", which the class then no longer joins.It only runs when a written number is left in the text. On digits and dots alone,
words2num_sentencereads a version or an address as a decimal, so the guard keeps them:A lone
onestays: it is a pronoun as often as a number, and the class already keeps it.num2words2is the inverse ofwords2num2and is what the new test writes the numbers with.How was this tested?
The new tests assert, through the published preset:
I paid fifty dollars.version 2.5.1,192.168.1.1,1.1.1.1keep their dotsnum2words2writes from 0 to 120, plus 999, 1234 and 10000, comes back as its digitsE2e rows added to
tests/e2e/files/gladia-3/en.csv:Fixes #42