Skip to content

Added cardinal semiotic class for te ITN#451

Open
jaya-TN wants to merge 12 commits into
NVIDIA:staging/telugu_itn_v1from
jaya-TN:feat-te-itn-cardinal-v2
Open

Added cardinal semiotic class for te ITN#451
jaya-TN wants to merge 12 commits into
NVIDIA:staging/telugu_itn_v1from
jaya-TN:feat-te-itn-cardinal-v2

Conversation

@jaya-TN

@jaya-TN jaya-TN commented Jul 7, 2026

Copy link
Copy Markdown

What does this PR do ?

This PR adds support for the Telugu Inverse Text Normalization (ITN) Cardinal semiotic class.

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 or (if your machine does not have GPU) pytest --cpu from the root folder (given you marked your test cases accordingly @pytest.mark.run_only_on('CPU')).
    2. Sparrowhawk tests bash tools/text_processing_deployment/export_grammars.sh --MODE=test ...
  • If you are adding a new feature: Have you added test cases for both pytest and Sparrowhawk here.
  • Have you added __init__.py for every folder and subfolder, including data folder which has .TSV files?
  • 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 Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. to all newly added Python files?
  • If you copied nemo_text_processing/text_normalization/en/graph_utils.py your header's second line should be Copyright 2015 and onwards Google, Inc.. See an example here.
  • Remove import guards (try import: ... except: ...) if not already done.
  • [] If you added a new language or a new feature please update the NeMo documentation (lives in different repo).
  • Have you added your language support to tools/text_processing_deployment/pynini_export.py.

PR Type:

  • New Feature
  • Bugfix
  • Documentation
  • Test

If you haven't finished some of the above items you can still open "Draft" PR.

jaya-TN added 2 commits July 7, 2026 16:13
Signed-off-by: jaya-TN <seruganti@nvidia.com>
Signed-off-by: jaya-TN <seruganti@nvidia.com>
@jaya-TN
jaya-TN marked this pull request as ready for review July 7, 2026 10:51
@jaya-TN
jaya-TN changed the base branch from main to staging/telugu_itn_v1 July 7, 2026 11:03
@jaya-TN jaya-TN changed the title te ITN: add cardinal semiotic class Added cardinal semiotic class for te ITN Jul 7, 2026
@mgrafu
mgrafu requested a review from folivoramanh July 10, 2026 19:39

@folivoramanh folivoramanh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • add sparrowhawk file and run sh test (we need to make sure both pytest and sparrowhawk pass)
  • add te to jenkins file
  • try to optimize cardinal logic (you can look up other languages eg. Hindi, Spanish, Portuguese, etc... for both TN and ITN) to optimize graph logic, too much looping could lead to slow runtime
  • do te ITN support english number (eg. 123456789?) if yes, can you add test cases for both te number and en number?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we need both hundred.tsv and hundred_words.tsv?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blank files, please modify or delete it

| (graph_ties_prefix + delete_space + graph_digit)
| self.graph_single_digit_with_zero
)
hundred_words = [row[0] for row in load_labels(get_abs_path("data/numbers/hundred_words.tsv"))]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why only row[0]?

MINUS = pynini.union("ఋణాత్మక", "మైనస్").optimize()


def integer_to_telugu(n: int) -> str:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we need a customize function for join string?

jaya-TN added 10 commits July 22, 2026 11:59
…nkins

Address review feedback on Telugu ITN cardinals:
- Rewrite cardinal grammar using the Hindi/Marathi fixed-width place-value
  chaining approach, cutting FST build from ~9.5min to <1s.
- Hardcode the closed-class magnitude words (hundred/thousand/lakh/crore)
  inline as in the hi/mr grammars and remove the redundant *_words.tsv data
  files (hundred_words, thousand_words, lakh_words, crore_words); also drop
  unused hundred.tsv, thousands.tsv and blank labels_exception.tsv.
- Add configurable numeral_system output (Telugu digits or English/Arabic
  digits) threaded through ClassifyFst, with test_cases_cardinal_en.txt and
  a dedicated pytest class.
- Fix tab delimiter in digit_people.tsv; remove custom integer_to_telugu.
- Add Sparrowhawk ITN test script and te stages to the Jenkinsfile, and
  register te in pynini_export.py.
Per review, do not mix te and te_en inside one grammar. Remove the
numeral_system parameter that rendered Telugu words as Arabic digits.
Telugu ITN now always outputs Telugu digits, and English/Arabic numerals
already present in the input pass through unchanged (123456789 -> 123456789),
mirroring the hi vs hi_en separation. The en test file now covers digit
pass-through rather than word-to-Arabic conversion.
English/Arabic numbers just pass through, so they are ordinary cardinal
cases rather than a separate concern. Fold the digit pass-through cases
into test_cases_cardinal.txt and drop the redundant test_cases_cardinal_en.txt
file and its dedicated test class.
Align Telugu ITN with the Hindi ITN grammar: convert only the number words
in a phrase and leave surrounding non-number words untouched (code-switching),
e.g. "ఆరు మంది ఆటగాళ్లు బయటకు" -> "౬ మంది ఆటగాళ్లు బయటకు". Remove the ASCII
numeral pass-through path and the corresponding 42~42 / 123456789 test cases,
since hi's cardinal has no such behaviour.
Mirror the Hindi ITN data/numbers layout by keeping the magnitude words as
single-column word lists (hundred.tsv, thousands.tsv) so future Telugu
semiotic classes (decimal/measure/money) can reuse them, just as hi does.
The cardinal grammar continues to hardcode these closed-class words exactly
like hi's cardinal.
- Support an explicit "ఒక" (one) before a bare magnitude, e.g. ఒక కోటి,
  ఒక లక్ష, ఒక వెయ్యి, ఒక వంద, which previously were not recognized.
- Add నూట (combining hundred form) to hundred.tsv.
- Extend cardinal test cases with edge cases: standalone magnitudes
  (నూరు/వెయ్యి/లక్ష/కోటి), counting-people forms (ఇద్దరు/ముగ్గురు/పది మంది),
  bare single digits, and the ఒక+magnitude forms.
Previously a case suffix (కి/కు/లో/తో/కోసం) following a number was deleted,
losing meaning (ఇరవైకి -> ౨౦) and swallowing spaced words (ఇరవై లో ఐదు -> ౨౦ ౫).
Now the suffix is preserved and attached to the numeral, with glued and spaced
inputs normalising to the same natural written form (ఇరవైకి / ఇరవై కి -> ౨౦కి).
Add test coverage for the suffix cases.
Only a glued case suffix is absorbed by the cardinal (ఇరవైకి -> ౨౦కి) so the
number is still recognised; a space-separated suffix keeps its space via the
word tagger (ఇరవై తో -> ౨౦ తో, ఇరవై మూడు కి -> ౨౩ కి). Update tests accordingly.
Forbid the cardinal number from consuming a trailing space so a spaced
suffix (e.g. "వంద కి") falls through to its own word token and keeps the
space ("౧౦౦ కి"), while a glued suffix ("వందకి" -> "౧౦౦కి") is still
absorbed. Fixes the residual gluing on numbers ending on a magnitude word.
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.

2 participants