X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=profanity_filter.py;h=22de26395bcf188a3300ecfdeec193246d233ded;hb=b93993dc08103ac47301556f8dd6fb8b71ee2551;hp=95540fa7b36f0bd8fcf813196e2f9f2390569fce;hpb=36fea7f15ed17150691b5b3ead75450e575229ef;p=python_utils.git diff --git a/profanity_filter.py b/profanity_filter.py index 95540fa..22de263 100755 --- a/profanity_filter.py +++ b/profanity_filter.py @@ -494,14 +494,12 @@ class ProfanityFilter(object): result = result.replace('3', 'e') for x in string.punctuation: result = result.replace(x, "") - chunks = [ - self.stemmer.stem(word) for word in nltk.word_tokenize(result) - ] + chunks = [self.stemmer.stem(word) for word in nltk.word_tokenize(result)] return ' '.join(chunks) def tokenize(self, text: str): for x in nltk.word_tokenize(text): - for y in re.split('\W+', x): + for y in re.split(r'\W+', x): yield y def contains_bad_word(self, text: str) -> bool: