We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 9 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(6)
我没有找到任何Python脏话库,所以我自己做了一个。
参数
filterlist
与禁用单词匹配的正则表达式列表。请不要使用
\b
,它将根据inside_words
插入。例子:
['bad', 'un\w+']
ignore_case
默认值:
True
不言自明。
replacements
默认值:
"$@%-?!"
一个字符串,其中的字符将随机生成替换字符串。
示例:
"%&$?!"
或"-"
等。complete
默认值:
True
控制是否整个字符串将被替换,或者是否保留第一个和最后一个字符。
inside_words
默认值:
False
控制是否也在其他单词内部搜索单词。禁用此
模块源
(示例在最后)
I didn't found any Python profanity library, so I made one myself.
Parameters
filterlist
A list of regular expressions that match a forbidden word. Please do not use
\b
, it will be inserted depending oninside_words
.Example:
['bad', 'un\w+']
ignore_case
Default:
True
Self-explanatory.
replacements
Default:
"$@%-?!"
A string with characters from which the replacements strings will be randomly generated.
Examples:
"%&$?!"
or"-"
etc.complete
Default:
True
Controls if the entire string will be replaced or if the first and last chars will be kept.
inside_words
Default:
False
Controls if words are searched inside other words too. Disabling this
Module source
(examples at the end)
您可以根据需要添加或删除坏词列表,arrBad。
You can add or remove from the bad words list,arrBad, as you please.
WebPurify 是一个适用于 Python 的亵渎过滤器库
WebPurify is a Profanity Filter Library for Python
您可以将 http://spambayes.sourceforge.net/ 和 http://www.cs.cmu.edu/~biglou/resources/bad-words.txt。
You could probably combine http://spambayes.sourceforge.net/ and http://www.cs.cmu.edu/~biglou/resources/bad-words.txt.
脏话?那是什么? ;-)
计算机真正能够识别脏话和咒骂还需要几年的时间,我真诚地希望人们到那时能够明白脏话是人性的,而不是“危险的”。
代替愚蠢的过滤器,要有一个聪明的人类主持人,他可以适当地平衡讨论的基调。一个可以检测滥用行为的主持人,例如:
“如果你是我的丈夫,我会在你的茶里下毒。” - “如果你是我的妻子,我会喝它。”
(顺便说一句,这是温斯顿·丘吉尔发来的。)
Profanity? What the f***'s that? ;-)
It will still take a couple of years before a computer will really be able to recognize swearing and cursing and it is my sincere hope that people will have understood by then that profanity is human and not "dangerous."
Instead of a dumb filter, have a smart human moderator who can balance the tone of discussion as appropriate. A moderator who can detect abuse like:
"If you were my husband, I'd poison your tea." - "If you were my wife, I'd drink it."
(that was from Winston Churchill, btw.)
当然,用户可以解决这个问题,但它应该做相当彻底的工作来消除脏话:
It's possible for users to work around this, of course, but it should do a fairly thorough job of removing profanity: