python亵渎过滤器
dictionary-profanity-filter的Python项目详细描述
字典亵渎过滤
用于使用字典进行亵渎过滤的python模块。 它支持现成的英语和俄语。
要求
- python 3.5或更高版本
如何安装
使用以下命令使用pip安装软件包:
pip install dictionary-profanity-filter
如何使用
下面是模块使用的几个示例:
- 创建亵渎过滤器实例:
fromdictionary_profanity_filterimportProfanityFilterprofanity_filter=ProfanityFilter()
- 将自定义单词添加到审查:
profanity_filter.add_words(['censorship','blocking'])profanity_filter.censor('I hate censorship and blocking!')# Output: 'I hate ********** and ********!'
- 检测文本中的错误单词:
profanity_filter.is_clean('Porn is a restricted word')# Output: False
- 从自定义词典中删除单词:
profanity_filter.remove_word('blocking')profanity_filter.censor('I hate censorship and blocking!')# Output: 'I hate ********** and blocking!'
待办事项
- []编写文档
- [X]编写测试