Skip to content

Commit 7b851fd

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

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+279
-195
lines changed

nemo_text_processing/inverse_text_normalization/en/taggers/date.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,7 @@ class DateFst(GraphFst):
147147
input_case: accepting either "lower_cased" or "cased" input.
148148
"""
149149

150-
def __init__(
151-
self,
152-
ordinal: GraphFst,
153-
input_case: str,
154-
project_input: bool = False
155-
):
150+
def __init__(self, ordinal: GraphFst, input_case: str, project_input: bool = False):
156151
super().__init__(name="date", kind="classify", project_input=project_input)
157152

158153
ordinal_graph = ordinal.graph

nemo_text_processing/inverse_text_normalization/en/taggers/decimal.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,7 @@ class DecimalFst(GraphFst):
8383
input_case: accepting either "lower_cased" or "cased" input.
8484
"""
8585

86-
def __init__(
87-
self,
88-
cardinal: GraphFst,
89-
input_case: str = INPUT_LOWER_CASED,
90-
project_input: bool = False
91-
):
86+
def __init__(self, cardinal: GraphFst, input_case: str = INPUT_LOWER_CASED, project_input: bool = False):
9287
super().__init__(name="decimal", kind="classify", project_input=project_input)
9388

9489
cardinal_graph = cardinal.graph_no_exception

nemo_text_processing/inverse_text_normalization/en/taggers/measure.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,7 @@ class MeasureFst(GraphFst):
4343
"""
4444

4545
def __init__(
46-
self,
47-
cardinal: GraphFst,
48-
decimal: GraphFst,
49-
input_case: str = INPUT_LOWER_CASED,
50-
project_input: bool = False
46+
self, cardinal: GraphFst, decimal: GraphFst, input_case: str = INPUT_LOWER_CASED, project_input: bool = False
5147
):
5248
super().__init__(name="measure", kind="classify", project_input=project_input)
5349

nemo_text_processing/inverse_text_normalization/en/taggers/money.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,7 @@ class MoneyFst(GraphFst):
4545
"""
4646

4747
def __init__(
48-
self,
49-
cardinal: GraphFst,
50-
decimal: GraphFst,
51-
input_case: str = INPUT_LOWER_CASED,
52-
project_input: bool = False
48+
self, cardinal: GraphFst, decimal: GraphFst, input_case: str = INPUT_LOWER_CASED, project_input: bool = False
5349
):
5450
super().__init__(name="money", kind="classify", project_input=project_input)
5551
# quantity, integer_part, fractional_part, currency

nemo_text_processing/inverse_text_normalization/en/taggers/ordinal.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,7 @@ class OrdinalFst(GraphFst):
3636
input_case: accepting either "lower_cased" or "cased" input.
3737
"""
3838

39-
def __init__(
40-
self,
41-
cardinal: GraphFst,
42-
input_case: str = INPUT_LOWER_CASED,
43-
project_input: bool = False
44-
):
39+
def __init__(self, cardinal: GraphFst, input_case: str = INPUT_LOWER_CASED, project_input: bool = False):
4540
super().__init__(name="ordinal", kind="classify", project_input=project_input)
4641

4742
cardinal_graph = cardinal.graph_no_exception

nemo_text_processing/inverse_text_normalization/en/taggers/telephone.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,7 @@ class TelephoneFst(GraphFst):
7575
input_case: accepting either "lower_cased" or "cased" input.
7676
"""
7777

78-
def __init__(
79-
self,
80-
cardinal: GraphFst,
81-
input_case: str = INPUT_LOWER_CASED,
82-
project_input: bool = False
83-
):
78+
def __init__(self, cardinal: GraphFst, input_case: str = INPUT_LOWER_CASED, project_input: bool = False):
8479
super().__init__(name="telephone", kind="classify", project_input=project_input)
8580
# country code, number_part, extension
8681
digit_to_str = (

nemo_text_processing/inverse_text_normalization/en/taggers/tokenize_and_classify.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
GraphFst,
3636
delete_extra_space,
3737
delete_space,
38-
generator_main,
3938
generate_far_filename,
39+
generator_main,
4040
)
4141
from nemo_text_processing.utils.logging import logger
4242

@@ -75,7 +75,7 @@ def __init__(
7575
operation="tokenize_and_classify",
7676
project_input=project_input,
7777
input_case=input_case,
78-
whitelist_file=whitelist
78+
whitelist_file=whitelist,
7979
)
8080
if not overwrite_cache and far_file and os.path.exists(far_file):
8181
self.fst = pynini.Far(far_file, mode="r")["tokenize_and_classify"]
@@ -91,12 +91,18 @@ def __init__(
9191
decimal = DecimalFst(cardinal, input_case=input_case, project_input=project_input)
9292
decimal_graph = decimal.fst
9393

94-
measure_graph = MeasureFst(cardinal=cardinal, decimal=decimal, input_case=input_case, project_input=project_input).fst
94+
measure_graph = MeasureFst(
95+
cardinal=cardinal, decimal=decimal, input_case=input_case, project_input=project_input
96+
).fst
9597
date_graph = DateFst(ordinal=ordinal, input_case=input_case, project_input=project_input).fst
9698
word_graph = WordFst(project_input=project_input).fst
9799
time_graph = TimeFst(input_case=input_case, project_input=project_input).fst
98-
money_graph = MoneyFst(cardinal=cardinal, decimal=decimal, input_case=input_case, project_input=project_input).fst
99-
whitelist_graph = WhiteListFst(input_file=whitelist, input_case=input_case, project_input=project_input).fst
100+
money_graph = MoneyFst(
101+
cardinal=cardinal, decimal=decimal, input_case=input_case, project_input=project_input
102+
).fst
103+
whitelist_graph = WhiteListFst(
104+
input_file=whitelist, input_case=input_case, project_input=project_input
105+
).fst
100106
punct_graph = PunctuationFst(project_input=project_input).fst
101107
electronic_graph = ElectronicFst(input_case=input_case, project_input=project_input).fst
102108
telephone_graph = TelephoneFst(cardinal, input_case=input_case, project_input=project_input).fst

nemo_text_processing/inverse_text_normalization/en/taggers/whitelist.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,7 @@ class WhiteListFst(GraphFst):
4040
input_case: accepting either "lower_cased" or "cased" input.
4141
"""
4242

43-
def __init__(
44-
self,
45-
input_case: str = INPUT_LOWER_CASED,
46-
input_file: str = None,
47-
project_input: bool = False
48-
):
43+
def __init__(self, input_case: str = INPUT_LOWER_CASED, input_file: str = None, project_input: bool = False):
4944
super().__init__(name="whitelist", kind="classify", project_input=project_input)
5045

5146
if input_file is None:

nemo_text_processing/inverse_text_normalization/en/verbalizers/measure.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,7 @@ class MeasureFst(GraphFst):
2929
cardinal: CardinalFst
3030
"""
3131

32-
def __init__(
33-
self,
34-
decimal: GraphFst,
35-
cardinal: GraphFst,
36-
project_input: bool = False
37-
):
32+
def __init__(self, decimal: GraphFst, cardinal: GraphFst, project_input: bool = False):
3833
super().__init__(name="measure", kind="verbalize", project_input=project_input)
3934
optional_sign = pynini.closure(pynini.cross("negative: \"true\"", "-"), 0, 1)
4035
unit = (

nemo_text_processing/inverse_text_normalization/en/verbalizers/verbalize_final.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
GraphFst,
2525
delete_extra_space,
2626
delete_space,
27-
generator_main,
2827
generate_far_filename,
28+
generator_main,
2929
)
3030
from nemo_text_processing.utils.logging import logger
3131

@@ -41,25 +41,16 @@ class VerbalizeFinalFst(GraphFst):
4141
overwrite_cache: set to True to overwrite .far files
4242
"""
4343

44-
def __init__(
45-
self,
46-
project_input: bool = False,
47-
cache_dir: str = None,
48-
overwrite_cache: bool = False
49-
):
44+
def __init__(self, project_input: bool = False, cache_dir: str = None, overwrite_cache: bool = False):
5045
super().__init__(name="verbalize_final", kind="verbalize")
5146

5247
far_file = None
5348
if cache_dir is not None and cache_dir != "None":
5449
os.makedirs(cache_dir, exist_ok=True)
5550
far_file = generate_far_filename(
56-
language="en",
57-
mode="itn",
58-
cache_dir=cache_dir,
59-
operation="verbalize",
60-
project_input=project_input
51+
language="en", mode="itn", cache_dir=cache_dir, operation="verbalize", project_input=project_input
6152
)
62-
53+
6354
if not overwrite_cache and far_file and os.path.exists(far_file):
6455
self.fst = pynini.Far(far_file, mode="r")["verbalize"]
6556
logger.info(f'VerbalizeFinalFst graph was restored from {far_file}.')
@@ -77,7 +68,7 @@ def __init__(
7768
+ pynutil.delete("}")
7869
)
7970
graph = delete_space + pynini.closure(graph + delete_extra_space) + graph + delete_space
80-
71+
8172
self.fst = graph.optimize()
8273
if far_file:
8374
generator_main(far_file, {"verbalize": self.fst})

0 commit comments

Comments
 (0)