Skip to content
Merged
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
6 changes: 3 additions & 3 deletions nemo_text_processing/text_normalization/data_loader_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ def evaluate(preds: List[str], labels: List[str], input: Optional[List[str]] = N
acc = acc + 1
else:
if input:
print(f"inpu: {json.dumps(input[i])}")
print(f"gold: {json.dumps(label_norm)}")
print(f"pred: {json.dumps(pred_norm)}")
print(f"input: {json.dumps(input[i], ensure_ascii=True)}")
print(f"gold: {json.dumps(label_norm, ensure_ascii=True)}")
print(f"pred: {json.dumps(pred_norm, ensure_ascii=True)}")
return acc / nums


Expand Down
6 changes: 5 additions & 1 deletion nemo_text_processing/text_normalization/normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,11 @@ def __init__(
from nemo_text_processing.text_normalization.ja.verbalizers.verbalize_final import VerbalizeFinalFst
elif lang == 'vi':
from nemo_text_processing.text_normalization.vi.taggers.tokenize_and_classify import ClassifyFst
from nemo_text_processing.text_normalization.vi.verbalizers.post_processing import PostProcessingFst
from nemo_text_processing.text_normalization.vi.verbalizers.verbalize_final import VerbalizeFinalFst

if post_process:
self.post_processor = PostProcessingFst(cache_dir=cache_dir, overwrite_cache=overwrite_cache)
else:
raise NotImplementedError(f"Language {lang} has not been supported yet.")

Expand Down Expand Up @@ -377,7 +381,7 @@ def normalize(
return text
output = SPACE_DUP.sub(' ', output[1:])

if self.lang == "en" and hasattr(self, 'post_processor'):
if self.lang in ["en", "vi"] and hasattr(self, 'post_processor'):
output = self.post_process(output)

if punct_post_process:
Expand Down
4 changes: 1 addition & 3 deletions nemo_text_processing/text_normalization/run_evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def parse_args():
parser.add_argument(
"--lang",
help="language",
choices=['ar', 'de', 'en', 'es', 'fr', 'hu', 'it', 'ru', 'sv', 'zh', 'hy', 'hi'],
choices=['ar', 'de', 'en', 'es', 'fr', 'hu', 'it', 'ru', 'sv', 'zh', 'hy', 'hi', 'vi'],
default="en",
type=str,
)
Expand Down Expand Up @@ -104,8 +104,6 @@ def parse_args():
print("- Accuracy: " + str(sum(token_weighted_accuracy) / sum(token_count_per_type.values())))
print(" - Total: " + str(sum(token_count_per_type.values())), '\n')

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

for token_type in token_accuracy:
if token_type not in known_types:
raise ValueError("Unexpected token type: " + token_type)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. 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.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
m mét
m2 mét vuông
m3 mét khối
m² mét vuông
m³ mét khối
g gam
l lít
s giây
v vôn
w oát
hz hẹc
A am pe
b bai
B byte
pa pascal
ω ohm
Ω ôm
h giờ
min phút
hr giờ
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
°f độ f
°c độ c
°k độ k
ha héc ta
mi mile
ft foot
inch inch
yd yard
% phần trăm
hp mã lực
rad radian
kwh ki lô oát giờ
kbps kilobit trên giây
mbps megabit trên giây
ghz gi ga hẹc
mhz mê ga hẹc
tw tê ra oát
kcal ki lô calo
gb gi ga bai
mb mê ga bai
mV mi li vôn
MV mê ga vôn
tb terabyte
pb petabyte
g gam
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
k ki lô
M mê ga
G gi ga
T tê ra
P pê ta
E ex xa
h hếc tô
da đề ca
d đề xi
c xăng ti
m mi li
µ mi crô
μ mi cờ rô
n na nô
p pi cô
f fem tô
a át tô
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
g gam
m mét
m² mét vuông
m2 mét vuông
m³ mét khối
m3 mét khối
l lít
B bai
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/giờ trên giờ
/g trên giờ
/h trên giờ
/ngày trên ngày
/d trên ngày
Expand All @@ -13,33 +12,17 @@
/lần một lần
/cái một cái
/chiếc một chiếc
/kg một ki lô gam
/g một gam
/cm một xăng ti mét
/m một mét
/km một ki lô mét
/cm² một xăng ti mét vuông
/m² một mét vuông
/m2 một mét vuông
/m³ một mét khối
/m3 một mét khối
/l một lít
/ml một mi li lít
/người một người
/chỗ một chỗ
/bài một bài
/trang một trang
/từ một từ
/đồng một đồng
/KB một kilobyte
/GB một gigabyte
/MB một megabyte
/TB một terabyte
/tấn một tấn
/đêm một đêm
/buổi một buổi
/ca một ca
/dự án một dự án
/lớp một lớp
/khóa một khóa
/suất một suất
/suất một suất
/tấn một tấn
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
k ki lô
M mê ga
G gi ga
c xăng ti
m mi li
T tê ra
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
1 một mốt
4 bốn tư
5 năm lăm
5 năm lăm
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
thousand nghìn
million triệu
billion tỷ
trillion nghìn tỷ
quadrillion triệu tỷ
quintillion tỷ tỷ
hundred trăm
linh linh
5 changes: 5 additions & 0 deletions nemo_text_processing/text_normalization/vi/graph_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ def extract_field(field_name):
return pynutil.delete(f"{field_name}:") + delete_space + pynutil.delete("\"") + quoted_text + pynutil.delete("\"")


def extract_wrapper_content(wrapper_type: str, content_graph):
"""Helper to extract content from wrapper like 'decimal { ... }'"""
return pynutil.delete(f"{wrapper_type} {{") + delete_space + content_graph + delete_space + pynutil.delete("}")


def convert_space(fst) -> "pynini.FstLike":
"""
Converts space to nonbreaking space.
Expand Down
Loading