Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nemo_text_processing/__init__.py

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 modify

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
# Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 0 additions & 2 deletions nemo_text_processing/inverse_text_normalization/__init__.py

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 modify

Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,3 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from nemo_text_processing.inverse_text_normalization.inverse_normalize import InverseNormalizer
1,398 changes: 1,398 additions & 0 deletions nemo_text_processing/inverse_text_normalization/blind_test_case.txt

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 publish blind test case to here

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
# 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.

do not modify

#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -146,6 +146,11 @@ def __init__(
from nemo_text_processing.inverse_text_normalization.ko.verbalizers.verbalize_final import (
VerbalizeFinalFst,
)
elif lang == 'ta': # Tamil
from nemo_text_processing.inverse_text_normalization.ta.taggers.tokenize_and_classify import ClassifyFst
from nemo_text_processing.inverse_text_normalization.ta.verbalizers.verbalize_final import (
VerbalizeFinalFst,
)
else:
raise NotImplementedError(f"Language {lang} has not been supported yet.")

Expand Down Expand Up @@ -211,6 +216,7 @@ def parse_args():
'mr',
'ja',
'ko',
'ta',
],
default="en",
type=str,
Expand Down
62 changes: 55 additions & 7 deletions nemo_text_processing/inverse_text_normalization/run_evaluate.py

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 add your language, do not modify the code

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.
# Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -43,9 +43,9 @@ def parse_args():
"es_en",
"fr",
"hi",
"hi_en",
"hy",
"ko",
"ta",
"mr",
"pt",
"ru",
Expand Down Expand Up @@ -78,7 +78,15 @@ def parse_args():
if args.lang == 'en':
from nemo_text_processing.inverse_text_normalization.en.clean_eval_data import filter_loaded_data
file_path = args.input
inverse_normalizer = InverseNormalizer(lang=args.lang, input_case=args.input_case)
print("Before creating InverseNormalizer")

inverse_normalizer = InverseNormalizer(
lang=args.lang,
input_case=args.input_case,
overwrite_cache=True,
)

print("After creating InverseNormalizer")

print("Loading training data: " + file_path)
if args.output_case == "lower_cased":
Expand All @@ -96,9 +104,9 @@ def parse_args():
sentences_un_normalized, sentences_normalized, _ = training_data_to_sentences(training_data)
print("- Data: " + str(len(sentences_normalized)) + " sentences")
sentences_prediction = inverse_normalizer.inverse_normalize_list(sentences_normalized)
with open('result.log', 'w') as ofp:
with open("result.log", "w", encoding="utf-8") as ofp:
for inp, out in zip(sentences_un_normalized, sentences_prediction):
ofp.write(f'{inp==out}; {inp}\t{out}\n')
ofp.write(f"{inp == out}; {inp}\t{out}\n")

print("- Denormalized. Evaluating...")
sentences_accuracy = evaluate(
Expand All @@ -109,20 +117,60 @@ def parse_args():
print("Token level evaluation...")
tokens_per_type = training_data_to_tokens(training_data, category=args.category)
token_accuracy = {}

for token_type in tokens_per_type:
print("- Token type: " + token_type)
tokens_un_normalized, tokens_normalized = tokens_per_type[token_type]
for i, (inp, out) in enumerate(zip(tokens_normalized, tokens_un_normalized)):
if "முப்பத்தி" in inp:
print("=" * 80)
print("Normalized :", repr(inp))
print("Expected :", repr(out))
print("Prediction :", repr(inverse_normalizer.inverse_normalize(inp, verbose=False)))
break
print(" - Data: " + str(len(tokens_normalized)) + " tokens")

tokens_prediction = inverse_normalizer.inverse_normalize_list(tokens_normalized)
for inp, pred, label in zip(tokens_normalized, tokens_prediction, tokens_un_normalized):
if inp == "இருநூற்று முப்பத்தி நான்காவது":
print("=" * 80)
print("Normalized :", repr(inp))
print("Expected :", repr(label))
print("Prediction :", repr(pred))
break

# Print all failed predictions
print(" - Failed cases:")
failed = 0
for inp, pred, label in zip(tokens_normalized, tokens_prediction, tokens_un_normalized):
if pred != label:
failed += 1
print("=" * 80)
print(f"Input : {inp}")
print(f"Expected : {label}")
print(f"Predicted : {pred}")

if failed == 0:
print(" None")

print(" - Denormalized. Evaluating...")
token_accuracy[token_type] = evaluate(tokens_prediction, tokens_un_normalized, input=tokens_normalized)
token_accuracy[token_type] = evaluate(
tokens_prediction,
tokens_un_normalized,
input=tokens_normalized,
)
print(" - Accuracy: " + str(token_accuracy[token_type]))

# =====================================================
# FIX: Add these back - they were accidentally removed
# =====================================================
token_count_per_type = {token_type: len(tokens_per_type[token_type][0]) for token_type in tokens_per_type}

token_weighted_accuracy = [
token_count_per_type[token_type] * accuracy for token_type, accuracy in token_accuracy.items()
]
print("- Accuracy: " + str(sum(token_weighted_accuracy) / sum(token_count_per_type.values())))

print("- Accuracy: " + str(sum(token_weighted_accuracy) / sum(token_count_per_type.values())))
print(" - Total: " + str(sum(token_count_per_type.values())), '\n')

for token_type in token_accuracy:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
ஒன்றின் ௧ இன்
இரண்டின் ௨ இன்
மூன்றின் ௩ இன்
நான்கின் ௪ இன்
ஐந்தின் ௫ இன்
ஆறின் ௬ இன்
ஏழின் ௭ இன்
எட்டின் ௮ இன்
ஒன்பதின் ௯ இன்
ஒன்றில் ௧ இல்
இரண்டில் ௨ இல்
மூன்றில் ௩ இல்
நான்கில் ௪ இல்
ஐந்தில் ௫ இல்
ஆறில் ௬ இல்
ஏழில் ௭ இல்
எட்டில் ௮ இல்
ஒன்பதில் ௯ இல்
பத்தின் ௧௦ இன்
பத்தில் ௧௦ இல்
பத்தொன்பதில் ௧௯ இல்
நூற்றில் ௧௦௦ இல்
நூற்றின் ௧௦௦ இன்
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
௧ ஒரு கோடி
௨ இரண்டு கோடி
௩ மூன்று கோடி
௪ நான்கு கோடி
௫ ஐந்து கோடி
௬ ஆறு கோடி
௭ ஏழு கோடி
௮ எட்டு கோடி
௯ ஒன்பது கோடி

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 to list all 10 to 99?

Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
௧௦ பத்து கோடி
௧௧ பதினொன்று கோடி
௧௨ பன்னிரண்டு கோடி
௧௩ பதின்மூன்று கோடி
௧௪ பதினான்கு கோடி
௧௫ பதினைந்து கோடி
௧௬ பதினாறு கோடி
௧௭ பதினேழு கோடி
௧௮ பதினெட்டு கோடி
௧௯ பத்தொன்பது கோடி
௨௦ இருபது கோடி
௨௧ இருபத்து ஒன்று கோடி
௨௨ இருபத்து இரண்டு கோடி
௨௩ இருபத்து மூன்று கோடி
௨௪ இருபத்து நான்கு கோடி
௨௫ இருபத்து ஐந்து கோடி
௨௬ இருபத்து ஆறு கோடி
௨௭ இருபத்து ஏழு கோடி
௨௮ இருபத்து எட்டு கோடி
௨௯ இருபத்து ஒன்பது கோடி
௩௦ முப்பது கோடி
௩௧ முப்பத்து ஒன்று கோடி
௩௨ முப்பத்து இரண்டு கோடி
௩௩ முப்பத்து மூன்று கோடி
௩௪ முப்பத்து நான்கு கோடி
௩௫ முப்பத்து ஐந்து கோடி
௩௬ முப்பத்து ஆறு கோடி
௩௭ முப்பத்து ஏழு கோடி
௩௮ முப்பத்து எட்டு கோடி
௩௯ முப்பத்து ஒன்பது கோடி
௪௦ நாற்பது கோடி
௪௧ நாற்பத்து ஒன்று கோடி
௪௨ நாற்பத்து இரண்டு கோடி
௪௩ நாற்பத்து மூன்று கோடி
௪௪ நாற்பத்து நான்கு கோடி
௪௫ நாற்பத்து ஐந்து கோடி
௪௬ நாற்பத்து ஆறு கோடி
௪௭ நாற்பத்து ஏழு கோடி
௪௮ நாற்பத்து எட்டு கோடி
௪௯ நாற்பத்து ஒன்பது கோடி
௫௦ ஐம்பது கோடி
௫௧ ஐம்பத்து ஒன்று கோடி
௫௨ ஐம்பத்து இரண்டு கோடி
௫௩ ஐம்பத்து மூன்று கோடி
௫௪ ஐம்பத்து நான்கு கோடி
௫௫ ஐம்பத்து ஐந்து கோடி
௫௬ ஐம்பத்து ஆறு கோடி
௫௭ ஐம்பத்து ஏழு கோடி
௫௮ ஐம்பத்து எட்டு கோடி
௫௯ ஐம்பத்து ஒன்பது கோடி
௬௦ அறுபது கோடி
௬௧ அறுபத்து ஒன்று கோடி
௬௨ அறுபத்து இரண்டு கோடி
௬௩ அறுபத்து மூன்று கோடி
௬௪ அறுபத்து நான்கு கோடி
௬௫ அறுபத்து ஐந்து கோடி
௬௬ அறுபத்து ஆறு கோடி
௬௭ அறுபத்து ஏழு கோடி
௬௮ அறுபத்து எட்டு கோடி
௬௯ அறுபத்து ஒன்பது கோடி
௭௦ எழுபது கோடி
௭௧ எழுபத்து ஒன்று கோடி
௭௨ எழுபத்து இரண்டு கோடி
௭௩ எழுபத்து மூன்று கோடி
௭௪ எழுபத்து நான்கு கோடி
௭௫ எழுபத்து ஐந்து கோடி
௭௬ எழுபத்து ஆறு கோடி
௭௭ எழுபத்து ஏழு கோடி
௭௮ எழுபத்து எட்டு கோடி
௭௯ எழுபத்து ஒன்பது கோடி
௮௦ எண்பது கோடி
௮௧ எண்பத்து ஒன்று கோடி
௮௨ எண்பத்து இரண்டு கோடி
௮௩ எண்பத்து மூன்று கோடி
௮௪ எண்பத்து நான்கு கோடி
௮௫ எண்பத்து ஐந்து கோடி
௮௬ எண்பத்து ஆறு கோடி
௮௭ எண்பத்து ஏழு கோடி
௮௮ எண்பத்து எட்டு கோடி
௮௯ எண்பத்து ஒன்பது கோடி
௯௦ தொண்ணூறு கோடி
௯௧ தொண்ணூற்று ஒன்று கோடி
௯௨ தொண்ணூற்று இரண்டு கோடி
௯௩ தொண்ணூற்று மூன்று கோடி
௯௪ தொண்ணூற்று நான்கு கோடி
௯௫ தொண்ணூற்று ஐந்து கோடி
௯௬ தொண்ணூற்று ஆறு கோடி
௯௭ தொண்ணூற்று ஏழு கோடி
௯௮ தொண்ணூற்று எட்டு கோடி
௯௯ தொண்ணூற்று ஒன்பது கோடி

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.

same question

Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
௧௦ பத்து கோடியே
௧௧ பதினொன்று கோடியே
௧௨ பன்னிரண்டு கோடியே
௧௩ பதின்மூன்று கோடியே
௧௪ பதினான்கு கோடியே
௧௫ பதினைந்து கோடியே
௧௬ பதினாறு கோடியே
௧௭ பதினேழு கோடியே
௧௮ பதினெட்டு கோடியே
௧௯ பத்தொன்பது கோடியே
௨௦ இருபது கோடியே
௨௧ இருபத்து ஒன்று கோடியே
௨௨ இருபத்து இரண்டு கோடியே
௨௩ இருபத்து மூன்று கோடியே
௨௪ இருபத்து நான்கு கோடியே
௨௫ இருபத்து ஐந்து கோடியே
௨௬ இருபத்து ஆறு கோடியே
௨௭ இருபத்து ஏழு கோடியே
௨௮ இருபத்து எட்டு கோடியே
௨௯ இருபத்து ஒன்பது கோடியே
௩௦ முப்பது கோடியே
௩௧ முப்பத்து ஒன்று கோடியே
௩௨ முப்பத்து இரண்டு கோடியே
௩௩ முப்பத்து மூன்று கோடியே
௩௪ முப்பத்து நான்கு கோடியே
௩௫ முப்பத்து ஐந்து கோடியே
௩௬ முப்பத்து ஆறு கோடியே
௩௭ முப்பத்து ஏழு கோடியே
௩௮ முப்பத்து எட்டு கோடியே
௩௯ முப்பத்து ஒன்பது கோடியே
௪௦ நாற்பது கோடியே
௪௧ நாற்பத்து ஒன்று கோடியே
௪௨ நாற்பத்து இரண்டு கோடியே
௪௩ நாற்பத்து மூன்று கோடியே
௪௪ நாற்பத்து நான்கு கோடியே
௪௫ நாற்பத்து ஐந்து கோடியே
௪௬ நாற்பத்து ஆறு கோடியே
௪௭ நாற்பத்து ஏழு கோடியே
௪௮ நாற்பத்து எட்டு கோடியே
௪௯ நாற்பத்து ஒன்பது கோடியே
௫௦ ஐம்பது கோடியே
௫௧ ஐம்பத்து ஒன்று கோடியே
௫௨ ஐம்பத்து இரண்டு கோடியே
௫௩ ஐம்பத்து மூன்று கோடியே
௫௪ ஐம்பத்து நான்கு கோடியே
௫௫ ஐம்பத்து ஐந்து கோடியே
௫௬ ஐம்பத்து ஆறு கோடியே
௫௭ ஐம்பத்து ஏழு கோடியே
௫௮ ஐம்பத்து எட்டு கோடியே
௫௯ ஐம்பத்து ஒன்பது கோடியே
௬௦ அறுபது கோடியே
௬௧ அறுபத்து ஒன்று கோடியே
௬௨ அறுபத்து இரண்டு கோடியே
௬௩ அறுபத்து மூன்று கோடியே
௬௪ அறுபத்து நான்கு கோடியே
௬௫ அறுபத்து ஐந்து கோடியே
௬௬ அறுபத்து ஆறு கோடியே
௬௭ அறுபத்து ஏழு கோடியே
௬௮ அறுபத்து எட்டு கோடியே
௬௯ அறுபத்து ஒன்பது கோடியே
௭௦ எழுபது கோடியே
௭௧ எழுபத்து ஒன்று கோடியே
௭௨ எழுபத்து இரண்டு கோடியே
௭௩ எழுபத்து மூன்று கோடியே
௭௪ எழுபத்து நான்கு கோடியே
௭௫ எழுபத்து ஐந்து கோடியே
௭௬ எழுபத்து ஆறு கோடியே
௭௭ எழுபத்து ஏழு கோடியே
௭௮ எழுபத்து எட்டு கோடியே
௭௯ எழுபத்து ஒன்பது கோடியே
௮௦ எண்பது கோடியே
௮௧ எண்பத்து ஒன்று கோடியே
௮௨ எண்பத்து இரண்டு கோடியே
௮௩ எண்பத்து மூன்று கோடியே
௮௪ எண்பத்து நான்கு கோடியே
௮௫ எண்பத்து ஐந்து கோடியே
௮௬ எண்பத்து ஆறு கோடியே
௮௭ எண்பத்து ஏழு கோடியே
௮௮ எண்பத்து எட்டு கோடியே
௮௯ எண்பத்து ஒன்பது கோடியே
௯௦ தொண்ணூறு கோடியே
௯௧ தொண்ணூற்று ஒன்று கோடியே
௯௨ தொண்ணூற்று இரண்டு கோடியே
௯௩ தொண்ணூற்று மூன்று கோடியே
௯௪ தொண்ணூற்று நான்கு கோடியே
௯௫ தொண்ணூற்று ஐந்து கோடியே
௯௬ தொண்ணூற்று ஆறு கோடியே
௯௭ தொண்ணூற்று ஏழு கோடியே
௯௮ தொண்ணூற்று எட்டு கோடியே
௯௯ தொண்ணூற்று ஒன்பது கோடியே
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
௧ ஒரு கோடியே
௨ இரண்டு கோடியே
௩ மூன்று கோடியே
௪ நான்கு கோடியே
௫ ஐந்து கோடியே
௬ ஆறு கோடியே
௭ ஏழு கோடியே
௮ எட்டு கோடியே
௯ ஒன்பது கோடியே
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
௧ ஒன்று
௧ ஒரு
௨ இரண்டு
௩ மூன்று
௪ நான்கு
௫ ஐந்து
௬ ஆறு
௭ ஏழு
௮ எட்டு
௯ ஒன்பது
Loading