Skip to content

Japanese TN fix and improvement#444

Open
folivoramanh wants to merge 2 commits into
NVIDIA:staging/ja_tn_v1from
folivoramanh:ja_tn
Open

Japanese TN fix and improvement#444
folivoramanh wants to merge 2 commits into
NVIDIA:staging/ja_tn_v1from
folivoramanh:ja_tn

Conversation

@folivoramanh

Copy link
Copy Markdown
Collaborator

What does this PR do ?

Add a one line overview of what this PR aims to accomplish.

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.

Signed-off-by: Mai Anh <palasek182@gmail.com>
@folivoramanh folivoramanh requested a review from mgrafu July 2, 2026 18:40
@folivoramanh folivoramanh self-assigned this Jul 2, 2026
@@ -0,0 +1,52 @@
A エー

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.

instead of mapping upper and lower case separately, let's add only one and capitalize the inputs in the graph itself

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

@mgrafu mgrafu Jul 9, 2026

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 full copyright in all files

@@ -0,0 +1,3 @@

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 shouldn't need to have the chars map to themselves, should be enough just to have the list of chars

@@ -0,0 +1,2 @@
Henry

@mgrafu mgrafu Jul 9, 2026

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 instead only use common terms like century or chapter, but not cover just a couple of king names

@@ -0,0 +1 @@
World War II World War II

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 do we preserve this?

@@ -14,26 +14,20 @@


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.

i think right now normalize.py isn't wired to use this. can you please include it so we have it for both pynini and sh?

@mgrafu

mgrafu commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

please update jenkinsfile

input=$PROJECT_DIR/ja/data_text_normalization/test_cases_whitelist.txt
runtest $input
}

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 test_range

Finite state transducer for classifying Japanese electronic expressions.

Examples:
abc@abc.com -> name: "abc アット abc ドット com"

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.

this should be the electronic class instead of 'name'

Finite state transducer for classifying Japanese address-like expressions.

Examples:
東京都千代田区丸の内1-1-1 -> name: "東京都千代田区丸の内一の一の一"

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 make sure all tagger outputs are fully formatted properly

@@ -1,5 +1,4 @@
ゼロ 0
零 0

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 did we change this only for ITN? and do we need to update test cases for this?

dr. ドクター
Mr. ミスター
mr. ミスター
Mrs. ミセス

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 not repeat terms in different tsv files, please keep in either this one or the original one


digit = pynini.string_file(get_abs_path("data/numbers/digit.tsv"))
zero = pynini.string_file(get_abs_path("data/numbers/zero.tsv"))
zero_maru = pynini.cross("0", "〇")

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 this as a tsv instead of hardcoding here

@@ -0,0 +1 @@
0 零

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 is this different from zero.tsv and both from the ITN zero?

graph_integer = (
pynutil.insert('integer_part: \"')
+ (
pynini.cross("0", "零")

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.

wouldn't this be zero_decimal?

def __init__(self, deterministic: bool = True):
super().__init__(name="punctuation", kind="classify", deterministic=deterministic)
s = "!#$%&'()*+,-./:;<=>?@^_`{|}。,;:《》“”·~【】!?、‘’.<>-——_、。.「」『』‘`/・;’”“”‷・〔〕々〃ゝゞヽ〲〱〳〴〵ヾ〆,~"
s = "!#$%&'()*+,-./:;<=>?@^_`{|}~"

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.

are we sure we don't need this punctuation?

Examples:
B2A23C -> name: "ビー 二 エー 二三 シー"
MIG-25/235212-asdg -> name: "エムアイジー ハイフン 二五 スラッシュ 二三五二一二 ハイフン エーエスディージー"
Room 301 -> name: "Room 三〇一"

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 would this be serial and not cardinal?

covid_style = special_word + pynutil.delete("-") + insert_space + (NEMO_DIGIT**2 @ cardinal.just_cardinals)

model_number = pynini.accep("型番") + insert_space + delimited
room_number = pynini.accep("Room") + pynutil.delete(" ") + insert_space + digit_group

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 definitely don't want something this restricted

division = pynini.string_file(get_abs_path("data/time/division.tsv"))

division_component = pynutil.insert("suffix: \"") + division + pynutil.insert("\"")
hour_number = pynutil.add_weight(pynini.cross("0", "零"), -0.1) | graph_cardinal

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.

again looks like zero_decimal?


@parameterized.expand(
[
("119", "百十九"),

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.

this should definitely not be here

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