logger = logging.getLogger(__name__)
@decorator_utils.singleton
class ProfanityFilter(object):
logger = logging.getLogger(__name__)
@decorator_utils.singleton
class ProfanityFilter(object):
self.stemmer = PorterStemmer()
def _normalize(self, text: str) -> str:
self.stemmer = PorterStemmer()
def _normalize(self, text: str) -> str:
result = result.replace('3', 'e')
for x in string.punctuation:
result = result.replace(x, "")
result = result.replace('3', 'e')
for x in string.punctuation:
result = result.replace(x, "")
return True
if len(words) > 1:
for bigram in string_utils.ngrams_presplit(words, 2):
bigram = ' '.join(bigram)
if self.is_bad_word(bigram):
return True
if len(words) > 1:
for bigram in string_utils.ngrams_presplit(words, 2):
bigram = ' '.join(bigram)
if self.is_bad_word(bigram):
return True
if len(words) > 2:
for trigram in string_utils.ngrams_presplit(words, 3):
trigram = ' '.join(trigram)
if self.is_bad_word(trigram):
return True
if len(words) > 2:
for trigram in string_utils.ngrams_presplit(words, 3):
trigram = ' '.join(trigram)
if self.is_bad_word(trigram):
def obscure_bad_words(self, text: str) -> str:
"""Obscure bad words that are detected by inserting random punctuation
characters.
"""
def obscure_bad_words(self, text: str) -> str:
"""Obscure bad words that are detected by inserting random punctuation
characters.
"""