Skip to content

Ar TN/TN#454

Open
ealbasiri wants to merge 13 commits into
NVIDIA:staging/ar_tn_v2from
ealbasiri:ar-tn-date
Open

Ar TN/TN#454
ealbasiri wants to merge 13 commits into
NVIDIA:staging/ar_tn_v2from
ealbasiri:ar-tn-date

Conversation

@ealbasiri

Copy link
Copy Markdown
Contributor

What does this PR do ?

Adds the Arabic (ar) grammar contributions: expanded cardinals, time, and date — each in both text normalization (TN) and inverse text normalization (ITN).

Scope (3 semiotic areas)

Cardinal (TN + ITN)

  • Expanded to millions via place-value 3-digit period decomposition.
  • Regenerated cardinal/fraction/decimal/money/measure test data to the new canonical spelling.

Time (TN + ITN)

  • HH:MM and HH:MM:SS, 24-hour, midnight handling.
  • Formal verbalization with correct feminine polarity for units and nominative tens in minutes/seconds; suffix (صباحًا/مساءً) and time-zone support.
  • ITN inverts the TN time verbalizer back to digit form.

Date (TN + ITN)

  • day–month–year, year–month–day, month–year, and bare-year forms.
  • Gregorian and Hijri month names (هـ / هجري).
  • numeric separators -, /, \, . (dotted requires full d.m.y so decimals stay decimals) and spelled-out months.
  • Ordinal day, idiomatic genitive year; standalone numbers stay cardinal.
  • ITN emits dd/mm[/yyyy] (or month name + year), Hijri suffix preserved.

Testing

  • pytest --cpu full ar suite: 399 passed, 0 failed.

Before your PR is "Ready for review"

Pre checks:

  • Have you signed your commits? (git commit -s)
  • Do all unittests finish successfully? pytest --cpu — 399 passed. (Sparrowhawk: not run.)
  • Added pytest test cases (cardinal/time/date + regenerated dependent data). (Sparrowhawk cases: not added.)
  • Added __init__.py for new data folders (months, ordinal, time).
  • Followed codeQL — no unused vars/imports in new files.
  • Correct license header on all new Python files.
  • en/graph_utils.py copy header — N/A.
  • Removed import guards — N/A.
  • Updated NeMo documentation — N/A (ar already documented).
  • Added language support to tools/text_processing_deployment/pynini_export.pyar already registered.

PR Type:

  • New Feature

ealbasiri and others added 13 commits April 27, 2023 16:57
Signed-off-by: ealbasiri <ealbasiri@gradcenter.cuny.edu>
Signed-off-by: anand-nv <105917641+anand-nv@users.noreply.github.com>
Signed-off-by: anand-nv <105917641+anand-nv@users.noreply.github.com>
Signed-off-by: anand-nv <105917641+anand-nv@users.noreply.github.com>
Signed-off-by: anand-nv <105917641+anand-nv@users.noreply.github.com>
…d fraction homograph

Cardinal (TN/ITN):
- Expand to millions with place-value 3-digit period decomposition
- Orthography: مئة (drop silent alif), مئتين, separated compound hundreds
  (ثلاث مئة), مئتي construct-state before counted nouns
- Use genitive tens (عشرين) and اثنين by default
- Fix counted-noun (تمييز) agreement: trailing 3-10 -> plural
  (110000 -> مئة وعشرة آلاف), otherwise singular; applied to آلاف and ملايين
Fraction (TN/ITN):
- Resolve homograph collision between dual fractions and cardinals by using
  construct-state dual denominators without final nun (سبعي=2/7 vs سبعين=70);
  both directions now round-trip losslessly
- Verbalizer accepts اثنين numerator
Tests:
- Fix pre-existing NameError (RUN_AUDIO_BASED_TESTS) in ar/test_measure.py
- Regenerate cardinal/fraction/decimal/money/measure test data (TN+ITN) to the
  new canonical spelling; decimal/money/measure grammars unchanged
- Full ar suite: 306 passed
TN (text_normalization/ar):
- Add time tagger + verbalizer for HH:MM, HH:MM:SS, and H <suffix> inputs
- Formal/regular style: hour as feminine ordinal (24h; midnight 0 -> الثانية عشرة),
  minutes/seconds as <number> دقيقة/دقائق
- Counted-noun agreement:
  * teens via 13_19 data (11 -> إحدى عشرة, 15 -> خمس عشرة)
  * 3-10 plural (خمس دقائق), 1 -> دقيقة واحدة, 2 -> دقيقتان
  * 21-59 ones digit feminized by polarity (خمس/ثمان/إحدى/اثنتان ...)
  * minutes/seconds number is nominative (عشرون/ثلاثون/أربعون/خمسون)
- Constrain suffix verbalization to suffix.tsv values (required for a clean inverse)
- Fix suffix.tsv tab separators
- Wire TimeFst into tokenize_and_classify.py and verbalize.py
- Add data: time/{suffix,time_zone}.tsv, ordinal/ordinals.tsv, number/{3_10mas,13_19}.tsv

ITN (inverse_text_normalization/ar):
- Add time tagger (inverts the TN time verbalizer) + verbalizer (-> HH:MM[:SS])
- Wire into tokenize_and_classify.py and verbalize.py

Tests:
- test_time.py: 30 TN (test_norm) + 19 ITN (test_denorm) hand-written cases
- Full ar suite: 355 passed
…months)

Signed-off-by: Enas Albasiri <ealbasiri@gradcenter.cuny.edu>
@@ -0,0 +1,113 @@
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. 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.

Copyright (c) 2026 for any new file

@@ -1 +1 @@
# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. 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.

unchanged for any existing files

@@ -1,4 +1,4 @@
# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.
# Copyright (c) 2023, 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.

let's add these 3 new test files to sparrowhawk test file too

)
self.final_graph_wo_negative = optional_graph_negative + self.final_graph_wo_sign

final_graph = self.add_tokens(self.final_graph_wo_negative)

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 we need to remove coverage for negatives?

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.

3 participants