Skip to content

en TN: verbalize ordinals in hyphenated compounds ("3rd-party" -> "third-party") - #537

Open
udsy19 wants to merge 1 commit into
NVIDIA:mainfrom
udsy19:fix/en-tn-hyphenated-ordinals
Open

udsy19 wants to merge 1 commit into
NVIDIA:mainfrom
udsy19:fix/en-tn-hyphenated-ordinals

Conversation

@udsy19

@udsy19 udsy19 commented Nov 17, 2026

Copy link
Copy Markdown

What does this PR do ?

Fixes English TN of ordinals inside hyphenated compounds. Today the serial tagger splits the ordinal suffix off as letters and reads the digits as a cardinal:

Input Before After
3rd-party three rd-party third-party
a 21st-century novel a twenty one st-century novel a twenty first-century novel
19th-century art nineteen th-century art nineteenth-century art
the 2nd-largest city the two nd-largest city the second-largest city

The fix adds a path to SerialFst for an ordinal followed by one or more -word groups. It composes the existing ordinal tagger with the ordinal verbalizer, the same pattern en/taggers/measure.py uses for addresses, and gives it MIN_NEG_WEIGHT so it is preferred over the letter split.

I added 5 cases to test_cases_serial.txt. All 5 fail on main and pass with this change.

Before your PR is "Ready for review"

Pre checks:

  • Have you signed your commits? Use git commit -s to sign.
  • Do all unittests finish successfully before sending PR?
    1. pytest tests/nemo_text_processing/en --cpu passes (1620 passed, 0 failed). test_serial.py also passes with --run_audio_based.
    2. Sparrowhawk tests: not run, because they need Docker, which isn't available on my machine. The new cases are in test_cases_serial.txt, which the Sparrowhawk test script also reads.
  • If you are adding a new feature: Have you added test cases for both pytest and Sparrowhawk here. (Added to en/data_text_normalization/test_cases_serial.txt.)
  • Have you added __init__.py for every folder and subfolder, including data folder which has .TSV files? (N/A: no new folders)
  • Have you followed codeQL results and removed unused variables and imports (report is at the bottom of the PR in github review box) ?
  • Have you added the correct license header to all newly added Python files? (N/A: no new files)
  • Remove import guards (try import: ... except: ...) if not already done.

PR Type:

  • New Feature
  • Bugfix
  • Documentation
  • Test

"3rd-party" was normalized to "three rd-party" and "21st-century" to
"twenty one st-century": the serial tagger split the ordinal suffix off
as a letter group and read the digits as a cardinal.

Add a serial path for an ordinal followed by hyphenated words, reusing
the ordinal tagger and verbalizer as the address grammar in measure.py
does, so "3rd-party" -> "third-party" and "19th-century" ->
"nineteenth-century".

Signed-off-by: Udaya Tejas <udayatejas2004@gmail.com>
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.

1 participant