Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jun 30, 2023
1 parent 6bec379 commit d5362cc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
# limitations under the License.

import pynini
from pynini.lib import pynutil
from nemo_text_processing.inverse_text_normalization.en.utils import get_abs_path
from nemo_text_processing.text_normalization.en.graph_utils import (
INPUT_CASED,
INPUT_LOWER_CASED,
GraphFst,
capitalized_input_graph
capitalized_input_graph,
)
from pynini.lib import pynutil


class ProfaneFst(GraphFst):
Expand All @@ -36,9 +36,7 @@ class ProfaneFst(GraphFst):
"""

def __init__(self, input_case: str = INPUT_LOWER_CASED):
super().__init__(
name="profane", kind="classify"
)
super().__init__(name="profane", kind="classify")
self.input_case = input_case
# Profane Grammar
profane_graph = pynini.string_file(get_abs_path("data/swear_sequences.tsv"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
from nemo_text_processing.inverse_text_normalization.en.taggers.electronic import ElectronicFst
from nemo_text_processing.inverse_text_normalization.en.taggers.measure import MeasureFst
from nemo_text_processing.inverse_text_normalization.en.taggers.money import MoneyFst
from nemo_text_processing.inverse_text_normalization.en.taggers.profane import ProfaneFst
from nemo_text_processing.inverse_text_normalization.en.taggers.ordinal import OrdinalFst
from nemo_text_processing.inverse_text_normalization.en.taggers.profane import ProfaneFst
from nemo_text_processing.inverse_text_normalization.en.taggers.punctuation import PunctuationFst
from nemo_text_processing.inverse_text_normalization.en.taggers.telephone import TelephoneFst
from nemo_text_processing.inverse_text_normalization.en.taggers.time import TimeFst
Expand Down Expand Up @@ -109,7 +109,6 @@ def __init__(
# Attempts to filter profane words only if `filter_profanity` field is set to True
if filter_profanity:
classify = (pynutil.add_weight(profane_graph, 0.0001) | classify).optimize()


punct = pynutil.insert("tokens { ") + pynutil.add_weight(punct_graph, weight=1.1) + pynutil.insert(" }")
token = pynutil.insert("tokens { ") + classify + pynutil.insert(" }")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# limitations under the License.

import pynini
from pynini.lib import pynutil
from nemo_text_processing.text_normalization.en.graph_utils import NEMO_NOT_QUOTE, GraphFst, delete_space
from pynini.lib import pynutil


class ProfaneFst(GraphFst):
Expand Down

0 comments on commit d5362cc

Please sign in to comment.