Skip to content

feat(itn/en): opt-in small_numbers_as_words for sentence mode (#109) - #113

Merged
Alex-Wengg merged 1 commit into
mainfrom
feat/109-keep-small-numbers
Nov 13, 2026
Merged

Alex-Wengg merged 1 commit into
mainfrom
feat/109-keep-small-numbers

Conversation

@Alex-Wengg

Copy link
Copy Markdown
Member

Fixes #109.

Adds NormalizeOptions::small_numbers_as_words, an opt-in for English sentence mode that applies two NeMo rules:

  • A lone "zero" to "twelve" stays a word (cardinal labels_exception).
  • "M to H" is a time only when a.m. or p.m. follows (graph_m_to_h_suffix_time). "quarter to five" still converts.

It is off by default, so current output doesn't change.

input default option on (= NeMo)
no one knows no 1 knows no one knows
children aged three to five children aged 04:57 children aged three to five
it takes two to three days it takes 02:58 days it takes two to three days
three to five pm 04:57 p.m. 04:57 p.m.
five dollars / one two three / thirteen $5 / 123 / 13 unchanged

API: normalize_sentence_lang_with_options (the ITN counterpart of the TN one), FFI nemo_normalize_sentence_lang_with_options, WASM normalizeSentenceLangWithOptions, plus a Swift overload and the headers, the same way #91 added roman_enumerators. nemo_normalize_sentence_with_options keeps its signature because FluidAudio calls it with four arguments, and a new argument would break its build on the next bump.

Unchanged by this PR: "five past three" stays as words (NeMo: 03:05), since sentence mode has no "M past H" rule. "eleven est" still reads 11:00 est (NeMo leaves it). Main behaves the same in both cases.

Tests:

  • Issue rows and edge cases, with the option on and off, in tests/en_tests.rs.
  • A unit test for the time tagger and an FFI test, including the off path and the fr path.
  • The new test avoids a lone "five", because test_custom_rules_all overrides that word globally while it runs.

Checks:

  • cargo test (default, ffi, release) and doctests pass.
  • FST parity and alignment pass, and NeMo parity has no regressions.
  • The wasm32 build passes.
  • The Swift smoke test passes 147/147, and the Swift wrapper type-checks.
  • cargo fmt --check passes, and clippy reports the same warnings as main.

🤖 Generated with Claude Code

NeMo's English grammar keeps everyday speech as words: a lone "zero" to
"twelve" stays a word (cardinal labels_exception), and "three to five"
is a time only when a.m. or p.m. follows (graph_m_to_h_suffix_time).
NormalizeOptions::small_numbers_as_words turns both on in sentence mode.
"quarter to five", "five dollars", "one two three" and numbers from
thirteen up still convert. Off by default, so output is unchanged.

Plumbing: normalize_sentence_lang_with_options (the ITN counterpart of
the TN one), FFI nemo_normalize_sentence_lang_with_options, WASM
normalizeSentenceLangWithOptions, a Swift overload and headers. The
existing nemo_normalize_sentence_with_options keeps its signature,
since FluidAudio calls it.
@Alex-Wengg
Alex-Wengg merged commit 202d4f4 into main Nov 13, 2026
6 of 7 checks passed
@Alex-Wengg Alex-Wengg mentioned this pull request Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sentence mode: an option to keep small numbers and "three to five" as words, like NeMo

1 participant