Repository navigation
feat(itn/en): opt-in small_numbers_as_words for sentence mode (#109) - #113
Merged
Merged
Conversation
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.
Merged
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.
Fixes #109.
Adds
NormalizeOptions::small_numbers_as_words, an opt-in for English sentence mode that applies two NeMo rules:labels_exception).graph_m_to_h_suffix_time). "quarter to five" still converts.It is off by default, so current output doesn't change.
API:
normalize_sentence_lang_with_options(the ITN counterpart of the TN one), FFInemo_normalize_sentence_lang_with_options, WASMnormalizeSentenceLangWithOptions, plus a Swift overload and the headers, the same way #91 addedroman_enumerators.nemo_normalize_sentence_with_optionskeeps 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:
tests/en_tests.rs.test_custom_rules_alloverrides that word globally while it runs.Checks:
cargo test(default, ffi, release) and doctests pass.wasm32build passes.cargo fmt --checkpasses, and clippy reports the same warnings as main.🤖 Generated with Claude Code