用于检查文本是否存在黑名单或白名单单词的包
checkword的Python项目详细描述
检查单词
用于检查文本是否包含黑名单或白名单单词的简单模块
安装
pip install checkword
用法
importcheckword# add some bad words to blacklistcheckword.add_bad_words(['some','bad','words','like','sheet'])# and good wordscheckword.add_good_words(['Festival','Event','Holiday'])print(checkword.blacklisted('My some text to check for bad words'))# Trueprint(checkword.whitelisted('Another text to check for good words'))# False
方法
add_bad_单词(单词)
add word or words list/tuple to blacklist
add_good_单词(单词)
add word or words list/tuple to whitelist
黑名单(text,match_case=false,words=true)
check if text contains any bad words
text: text for checking
match_case: use case sensitive word matching. if Truecheckword.blacklisted('bAd')
will be False when'bad'
is in blacklist
words: match only complete words. if Truecheckword.blacklisted('my bad string')=True
andcheckword.blacklisted('mybadstring')=False
while'bad'
is in blacklist
whitelisted(text,match_case=false,words=true)
check if text contains any whitelisted words
text: text for checking
match_case: use case sensitive word matching. if Truecheckword.whitelisted('gOoD')
will be False when'good'
is in blacklist
words: match only complete words. if Truecheckword.whitelisted('my good string')=True
andcheckword.whitelisted('mygoodstring')=False
while'good'
is in blacklist
remove_bad_单词(单词)
remove bad word from blacklist
删除“好”字(字)
remove good word from whitelist
清除黑名单()
remove all bad words from blacklist
clear_whitelist()
remove all good words from whitelist