Skip to content

Added cardinal semiotic class for te ITN - #451

Open
jaya-TN wants to merge 1 commit 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 1 commit 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
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?

Comment thread nemo_text_processing/inverse_text_normalization/te/taggers/cardinal.py Outdated
Comment thread nemo_text_processing/inverse_text_normalization/te/graph_utils.py Outdated
@jaya-TN
jaya-TN force-pushed the feat-te-itn-cardinal-v2 branch from 33c98ab to f5bb3de Compare July 29, 2026 14:01
Add the Telugu (te) cardinal semiotic class for ITN: taggers, verbalizers,
data files, graph_utils and utils. Uses the Indian numbering system
(hundred/thousand/lakh/crore) with a fixed-width place-value graph and native
Telugu digit output; English digits are passed through. The number lexicon is
data-driven via TSV files. Adds pytest cases and a Sparrowhawk test, and
registers te in the Jenkinsfile and pynini_export.

Signed-off-by: jaya-TN <seruganti@nvidia.com>
@jaya-TN
jaya-TN force-pushed the feat-te-itn-cardinal-v2 branch from f5bb3de to ddc54ad Compare July 29, 2026 14:06

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 first and second line got only 1 value while third row got 2?

super().__init__(name="cardinal", kind="classify")
self.input_case = input_case

graph_zero = pynini.string_file(get_abs_path("data/numbers/zero.tsv")).invert()

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.

do not abuse .invert(), try to standardize the data

two_te_digits = NEMO_TE_DIGIT + NEMO_TE_DIGIT
graph_digit |= (graph_people | graph_special) @ NEMO_TE_DIGIT

self.graph_zero = graph_zero

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.

only set self.variable when it's reusable on other semiotic class

self.graph_two_digit = graph_two_digit
two_digit_or_zeros = graph_two_digit | pynutil.insert("౦౦")

graph_case_suffix = pynini.string_file(get_abs_path("data/numbers/case_suffix.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.

move all pynini.string_file call to begin of init function for easier checking file call

@@ -0,0 +1,142 @@
# Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved.

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.

change all 2 first lines to
"# Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#"

@pytest.mark.run_only_on('CPU')
@pytest.mark.unit
def test_denorm(self, test_input, expected):
tagged = pynini.shortestpath(test_input @ self.tagger).string()

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.

read hindi test and use the same code, do not use pynini.shortestpath here

args = parse_args()

if args.language in ['ru', 'es_en', 'hi_en', 'mr'] and args.grammars == 'tn_grammars':
if args.language in ['ru', 'es_en', 'hi_en', 'mr', 'te'] and args.grammars == 'tn_grammars':

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.

we also have PIC for te TN, right? if yes, please remove this change

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