Skip to content
Closed
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
30 changes: 30 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pipeline {
JA_TN_CACHE='/home/jenkins/TestData/text_norm/ci/grammars/10-17-24-1'
KO_TN_CACHE='/home/jenkins/TestData/text_norm/ci/grammars/06-04-25-6'
KO_TN_CACHE='/home/jenkins/TestData/text_norm/ci/grammars/07-29-26-1'
TA_TN_CACHE='/home/jenkins/TestData/text_norm/ci/grammars/09-16-26-0'
DEFAULT_TN_CACHE='/home/jenkins/TestData/text_norm/ci/grammars/06-08-23-0'
}
stages {
Expand Down Expand Up @@ -113,6 +114,30 @@ pipeline {
}
}

stage('L0: Create TA TN/ITN Grammars') {
when {
anyOf {
branch 'main'
branch 'staging/**'
branch 'staging_*'
changeRequest target: 'main'
}
}
failFast true
parallel {
stage('L0: Ta TN grammars') {
steps {
sh 'CUDA_VISIBLE_DEVICES="" python nemo_text_processing/text_normalization/normalize.py --lang=ta --text="௧" --cache_dir ${TA_TN_CACHE}'
}
}
stage('L0: Ta ITN grammars') {
steps {
sh 'CUDA_VISIBLE_DEVICES="" python nemo_text_processing/inverse_text_normalization/inverse_normalize.py --lang=ta --text="ஒன்று" --cache_dir ${TA_TN_CACHE}'
}
}
}
}

stage('L0: Create DE/ES TN/ITN Grammars') {
when {
anyOf {
Expand Down Expand Up @@ -408,6 +433,11 @@ pipeline {
sh 'CUDA_VISIBLE_DEVICES="" pytest tests/nemo_text_processing/hi/ -m "not pleasefixme" --cpu --tn_cache_dir ${HI_TN_CACHE}'
}
}
stage('L1: Run all TA TN/ITN tests (restore grammars from cache)') {
steps {
sh 'CUDA_VISIBLE_DEVICES="" pytest tests/nemo_text_processing/ta/ -m "not pleasefixme" --cpu --tn_cache_dir ${TA_TN_CACHE}'
}
}
stage('L1: Run all Codeswitched ES/EN TN/ITN tests (restore grammars from cache)') {
steps {
sh 'CUDA_VISIBLE_DEVICES="" pytest tests/nemo_text_processing/es_en/ -m "not pleasefixme" --cpu --tn_cache_dir ${ES_EN_TN_CACHE}'
Expand Down
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def parse_args():
"vi",
"zh",
'ja',
"ta",
],
default="en",
type=str,
Expand Down
17 changes: 17 additions & 0 deletions nemo_text_processing/inverse_text_normalization/ta/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (c) 2026, 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.

from nemo_text_processing.inverse_text_normalization.ta.taggers.tokenize_and_classify import ClassifyFst
from nemo_text_processing.inverse_text_normalization.ta.verbalizers.verbalize import VerbalizeFst
from nemo_text_processing.inverse_text_normalization.ta.verbalizers.verbalize_final import VerbalizeFinalFst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) 2026, 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,13 @@
# Copyright (c) 2026, 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,28 @@
ஒன்றில் ஒன்று
இரண்டில் இரண்டு
மூன்றில் மூன்று
நான்கில் நான்கு
ஐந்தில் ஐந்து
ஆறில் ஆறு
ஏழில் ஏழு
எட்டில் எட்டு
ஒன்பதில் ஒன்பது
பத்தில் பத்து
பதினொன்றில் பதினொன்று
பன்னிரண்டில் பன்னிரண்டு
இருபதில் இருபது
முப்பதில் முப்பது
நாற்பதில் நாற்பது
ஐம்பதில் ஐம்பது
அறுபதில் அறுபது
எழுபதில் எழுபது
எண்பதில் எண்பது
தொண்ணூறில் தொண்ணூறு
நூறில் நூறு
பதின்மூன்றில் பதின்மூன்று
பதினான்கில் பதினான்கு
பதினைந்தில் பதினைந்து
பதினாறில் பதினாறு
பதினேழில் பதினேழு
பதினெட்டில் பதினெட்டு
பத்தொன்பதில் பத்தொன்பது
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) 2026, 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,13 @@
ரூபாய் ₹
ரூபாய்கள் ₹
டாலர் $
டாலர்கள் $
பவுண்ட் £
பவுண்ட்கள் £
யூரோ €
யூரோக்கள் €
யென் ¥
வான் ₩
லீரா ₺
டாக்கா ৳
நைரா ₦
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
காசு ₹
காசுகள் ₹
பைசாக்கள் ₹
சென்ட்கள் $
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) 2026, 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,5 @@
ஒரு licensed 1
ஓர் licensed 1
கால் standalone 0.25
அரை standalone 0.5
முக்கால் standalone 0.75
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
அரை 0 5
ஒன்றரை 1 5
இரண்டரை 2 5
மூன்றரை 3 5
நான்கரை 4 5
நாலரை 4 5
ஐந்தரை 5 5
ஆறரை 6 5
ஏழரை 7 5
எட்டரை 8 5
ஒன்பதரை 9 5
பத்தரை 10 5
கால் 0 25
முக்கால் 0 75
ஒண்ணரை 1 5
ரெண்டரை 2 5
மூணரை 3 5
அஞ்சரை 5 5
ஒன்னரை 1 5
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ஆயிரம் 3 expand
இலட்சம் 5 keep
லட்சம் 5 keep
கோடி 7 keep
மில்லியன் 6 keep
பில்லியன் 9 keep
டிரில்லியன் 12 keep
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) 2026, 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,9 @@
ஒன்று சேர் idiomatic verb "unite", not the numeral one
ஒன்று சேர்ந்து idiomatic verb "unite", not the numeral one
ஒன்று சேர்ந்த idiomatic verb "unite", not the numeral one
ஒன்று சேர்க்க idiomatic verb "unite", not the numeral one
ஒன்று கூடி idiomatic verb "assemble", not the numeral one
ஒன்று கூடு idiomatic verb "assemble", not the numeral one
ஒன்று கூடிய idiomatic verb "assemble", not the numeral one
ஒன்று போல "alike"; ஒன்று is the pronoun here
எல்லாம் ஒன்று "all is one"; ஒன்று is the pronoun here
110 changes: 110 additions & 0 deletions nemo_text_processing/inverse_text_normalization/ta/graph_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# Copyright 2015 and onwards Google, Inc.
#
# 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.

import logging
import os
from pathlib import Path
from typing import Dict

import pynini
from pynini import Far
from pynini.export import export
from pynini.lib import pynutil

from nemo_text_processing.text_normalization.en.graph_utils import NEMO_SIGMA, delete_space


def generator_main(file_name: str, graphs: Dict[str, 'pynini.FstLike']):
"""
Exports graph as OpenFst finite state archive (FAR) file with given file name and rule name.

Args:
file_name: exported file name
graphs: Mapping of a rule name and Pynini WFST graph to be exported
"""
exporter = export.Exporter(file_name)
for rule, graph in graphs.items():
exporter[rule] = graph.optimize()
exporter.close()
logging.info(f'Created {file_name}')


class GraphFst:
"""
Base class for all grammar fsts.

Args:
name: name of grammar class
kind: either 'classify' or 'verbalize'
deterministic: if True will provide a single transduction option,
for False multiple transduction are generated (used for audio-based normalization)
"""

def __init__(self, name: str, kind: str, deterministic: bool = True):
self.name = name
self.kind = kind
self._fst = None
self.deterministic = deterministic

self.far_path = Path(os.path.dirname(__file__) + '/grammars/' + kind + '/' + name + '.far')
if self.far_exist():
self._fst = Far(self.far_path, mode="r", arc_type="standard", far_type="default").get_fst()

def far_exist(self) -> bool:
"""
Returns true if FAR can be loaded
"""
return self.far_path.exists()

@property
def fst(self) -> 'pynini.FstLike':
return self._fst

@fst.setter
def fst(self, fst):
self._fst = fst

def add_tokens(self, fst) -> 'pynini.FstLike':
"""
Wraps class name around to given fst

Args:
fst: input fst

Returns:
Fst: fst
"""
return pynutil.insert(f"{self.name} {{ ") + fst + pynutil.insert(" }")

def delete_tokens(self, fst) -> 'pynini.FstLike':
"""
Deletes class name wrap around output of given fst

Args:
fst: input fst

Returns:
Fst: fst
"""
res = (
pynutil.delete(f"{self.name}")
+ delete_space
+ pynutil.delete("{")
+ delete_space
+ fst
+ delete_space
+ pynutil.delete("}")
)
return res @ pynini.cdrewrite(pynini.cross(" ", " "), "", "", NEMO_SIGMA)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) 2026, 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.
Loading