Skip to content

De ITN: Fraction decoupled v2 - #525

Open
adelina23dunina wants to merge 7 commits into
NVIDIA:staging/de_tn_itn_v2from
adelina23dunina:de_itn_fraction_decoupled_v2
Open

adelina23dunina wants to merge 7 commits into
NVIDIA:staging/de_tn_itn_v2from
adelina23dunina:de_itn_fraction_decoupled_v2

Conversation

@adelina23dunina

Copy link
Copy Markdown

What does this PR do ?

Decouples the German ITN fraction tagger and verbalizer from the TN grammar.

The numerator and the denominator are now built from the ITN cardinal, the denominator stem comes from the ITN ordinal, and the data they need lives in data/fractions/ (half.tsv, suffixes.tsv) and data/numbers/digits.tsv. The verbalizer is new on the ITN side and is registered in verbalize.py, so the class is verbalized by its own grammar instead of the TN one.

taggers/ordinal.py changes by four lines only: the ordinal stem is exposed as self.ordinal_stem so the fraction denominator can reuse it instead of rebuilding the table.

Two commits expose graphs that have no consumer in this PR yet, self.graph_wo_negative in the tagger and self.numbers in the verbalizer. They are what the measure grammar will consume in the next step, in the same spirit as self.graph_ordinals in the ordinal tagger.

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) 2021, 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

Signed-off-by: Adelina Dunina <adunina@nvidia.com>
The Sparrowhawk Fraction message has no quantity field, so a fraction with
a magnitude word failed to parse and the string stayed unnormalised. None of
the other fraction grammars in the repository carry that field either.
The non-deterministic magnitude abbreviations
went with it, which leaves the tagger with no use for the deterministic flag.

The space between two fields is now read from the input with NEMO_SPACE
instead of being inserted and deleted separately, the way the Spanish tagger
does it.

The graph the other classes consume is renamed to graph_fraction_raw.

Signed-off-by: Adelina Dunina <adunina@nvidia.com>
Signed-off-by: Adelina Dunina <adunina@nvidia.com>
Signed-off-by: Adelina Dunina <adunina@nvidia.com>
Signed-off-by: Adelina Dunina <adunina@nvidia.com>
Signed-off-by: Adelina Dunina <adunina@nvidia.com>
@adelina23dunina adelina23dunina changed the title De itn fraction decoupled v2 De ITN: Fraction decoupled v2 Oct 29, 2026
@adelina23dunina

Copy link
Copy Markdown
Author

Hi @folivoramanh ! Could you please review it when you get a chance? Thank you!

@folivoramanh
folivoramanh self-requested a review November 1, 2026 07:22
eins 1
ein 1
einer 1
einen 1

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.

is this missing and newly add?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, I noticed that some case endings for "ein" (one) were missing. Everything is fine now, these new additions also make it possible to get rid of hardcoded elements in fraction

vier drei viertel~4 3/4
minus vier drei viertel~-4 3/4
ein millionstel~1/1000000
das viertel ist schön~das viertel ist schön

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.

if it's not fraction case, pls remove

@adelina23dunina adelina23dunina Nov 2, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Hi Anh, thank you for the review! It was explained in the docstring but I removed it in order to follow the other languages pattern. I use "das viertel ist schön~das viertel ist schön" as a guard test: input equals output, so it pins the rule that a fraction requires a numerator. A bare denominator is not converted (viertel - 1/4), because Viertel is also an ordinary noun — a city district — so an implicit numerator of 1 would turn "das Viertel ist schön" (the neighborhood is nice) into "das 1/4 ist schön" (so fractions without a numerator are not converted)

Signed-off-by: Adelina Dunina <adunina@nvidia.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.

2 participants