15 lines
403 B
Python
15 lines
403 B
Python
|
|
from better_profanity import profanity
|
||
|
|
|
||
|
|
profanity.load_censor_words()
|
||
|
|
|
||
|
|
class ContentModerator:
|
||
|
|
def is_clean(self, text: str) -> bool:
|
||
|
|
if not isinstance(text, str):
|
||
|
|
return True
|
||
|
|
return not profanity.contains_profanity(text.strip())
|
||
|
|
|
||
|
|
def censor(self, text: str) -> str:
|
||
|
|
if not isinstance(text, str):
|
||
|
|
return text
|
||
|
|
return profanity.censor(text)
|