Skip to content

Commit c57c930

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 2df93bc commit c57c930

File tree

14 files changed

+279
-121
lines changed

14 files changed

+279
-121
lines changed

nemo_text_processing/text_normalization/vi/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
# distributed under the License is distributed on an "AS IS" BASIS,
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
13-
# limitations under the License.
13+
# limitations under the License.

nemo_text_processing/text_normalization/vi/taggers/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
# distributed under the License is distributed on an "AS IS" BASIS,
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
13-
# limitations under the License.
13+
# limitations under the License.

nemo_text_processing/text_normalization/vi/taggers/cardinal.py

Lines changed: 250 additions & 97 deletions
Large diffs are not rendered by default.

nemo_text_processing/text_normalization/vi/taggers/punctuation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ def __init__(self, deterministic: bool = True):
5454
graph = pynutil.insert('name: "') + punct + pynutil.insert('"')
5555

5656
final_graph = pynutil.insert("punctuation { ") + graph + pynutil.insert(" }")
57-
self.fst = final_graph.optimize()
57+
self.fst = final_graph.optimize()

nemo_text_processing/text_normalization/vi/taggers/tokenize_and_classify.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ def __init__(
4646
far_file = None
4747
if cache_dir is not None and cache_dir != "None":
4848
os.makedirs(cache_dir, exist_ok=True)
49-
far_file = os.path.join(cache_dir, f"vi_tn_{deterministic}_deterministic_{input_case}_tokenize.far",)
49+
far_file = os.path.join(
50+
cache_dir,
51+
f"vi_tn_{deterministic}_deterministic_{input_case}_tokenize.far",
52+
)
5053
if not overwrite_cache and far_file and os.path.exists(far_file):
5154
self.fst = pynini.Far(far_file, mode="r")["tokenize_and_classify"]
5255
logger.info(f"ClassifyFst.fst was restored from {far_file}.")
@@ -73,9 +76,9 @@ def __init__(
7376
logger.debug(f"word: {time.time() - start_time: .2f}s -- {word_graph.num_states()} nodes")
7477

7578
classify = (
76-
pynutil.add_weight(whitelist_graph, 0.8)
77-
| pynutil.add_weight(cardinal_graph, 0.9)
78-
| pynutil.add_weight(word_graph, 100)
79+
pynutil.add_weight(whitelist_graph, 0.8)
80+
| pynutil.add_weight(cardinal_graph, 0.9)
81+
| pynutil.add_weight(word_graph, 100)
7982
)
8083
punct = pynutil.insert("tokens { ") + pynutil.add_weight(punct_graph, weight=2.1) + pynutil.insert(" }")
8184
token = pynutil.insert("tokens { ") + classify + pynutil.insert(" }")
@@ -89,4 +92,4 @@ def __init__(
8992
self.fst = graph.optimize()
9093

9194
if far_file:
92-
generator_main(far_file, {"tokenize_and_classify": self.fst})
95+
generator_main(far_file, {"tokenize_and_classify": self.fst})

nemo_text_processing/text_normalization/vi/taggers/whitelist.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
import pynini
1616
from pynini.lib import pynutil
1717

18-
from nemo_text_processing.text_normalization.vi.utils import get_abs_path, load_labels
1918
from nemo_text_processing.text_normalization.en.graph_utils import GraphFst, convert_space
19+
from nemo_text_processing.text_normalization.vi.utils import get_abs_path, load_labels
2020

2121

2222
class WhiteListFst(GraphFst):
@@ -67,4 +67,4 @@ def _get_whitelist_graph(input_case, file):
6767
self.fst = (pynutil.insert("name: \"") + self.final_graph + pynutil.insert("\"")).optimize()
6868

6969
# Add tokens wrapper
70-
self.fst = self.add_tokens(self.fst)
70+
self.fst = self.add_tokens(self.fst)

nemo_text_processing/text_normalization/vi/taggers/word.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ class WordFst(GraphFst):
3131
def __init__(self, deterministic: bool = True):
3232
super().__init__(name="word", kind="classify", deterministic=deterministic)
3333
word = pynutil.insert("name: \"") + pynini.closure(NEMO_NOT_SPACE, 1) + pynutil.insert("\"")
34-
self.fst = word.optimize()
34+
self.fst = word.optimize()

nemo_text_processing/text_normalization/vi/verbalizers/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
# distributed under the License is distributed on an "AS IS" BASIS,
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
13-
# limitations under the License.
13+
# limitations under the License.

nemo_text_processing/text_normalization/vi/verbalizers/cardinal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ def __init__(self, deterministic: bool = True):
5252

5353
# Delete the token structure and create final FST
5454
delete_tokens = self.delete_tokens(self.numbers)
55-
self.fst = delete_tokens.optimize()
55+
self.fst = delete_tokens.optimize()

nemo_text_processing/text_normalization/vi/verbalizers/verbalize.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def __init__(self, deterministic: bool = True):
2525
# Initialize verbalizers
2626
cardinal = CardinalFst(deterministic=deterministic)
2727
cardinal_graph = cardinal.fst
28-
28+
2929
whitelist = WhiteListFst(deterministic=deterministic)
3030
whitelist_graph = whitelist.fst
3131

@@ -35,4 +35,4 @@ def __init__(self, deterministic: bool = True):
3535
# Combine all verbalizers
3636
graph = cardinal_graph | whitelist_graph | word_graph
3737

38-
self.fst = graph
38+
self.fst = graph

0 commit comments

Comments
 (0)