python (django) 中的垃圾邮件和脏话评论帖子过滤/预防/阻止

发布于 2024-09-02 08:51:41 字数 490 浏览 9 评论 0原文

我的基本问题是如何在 python (django) 下的评论发布系统中防止垃圾邮件和脏话。

我有一组要阻止的短语(大约 3000 个短语)。

我想做的是这样的:

如果当用户单击发布按钮时我发现一条评论有脏话,那么网络应该弹出一条警告消息并要求人们重新输入/更正评论并再次提交。这只是防止人们提交粗鲁/垃圾评论。

问题(1),是否有任何现有的开源python(或django)包/模块/插件可以处理这项工作?我知道有一个叫 Akismet 的人。但据我了解,这并不能解决我的问题。 Akismet 只是一个网络服务,可以过滤 Akismet 定义的单词词典。但我有自己的词汇集。如果我错了,请纠正我。

问题(2),如果没有这样的开源包我可以使用,如何创建我自己的一个?我唯一能想到的就是使用正则表达式并将所有单词短语用“或”连接到正则表达式中。但我有 3000 个短语,我认为它在性能和过滤每个评论帖子方面不起作用。有什么建议我应该从哪里开始?

非常感谢您的帮助和时间。

My basic question is how to prevent spam and dirty words in a comment post system under python (django).

I have a collection of phrases (approximately 3000 phrases) to be blocked.

What I want to do is like this:

If I found a comment which has a dirty-word when user clicks the post button, then the web should popup a warning message and asked people to re-enter/correct the comments and submit it again. This is just preventing people to submit rude/spam comments.

Question (1), are there any existing open source python (or django) package/module/plugin which can handle this job? I knew there was one called Akismet. But from what I understood, it will not solve my problem. Akismet is just a web service and filter the words dictionary defined by Akismet. But I have my own collection of words. Please correct me if I am wrong.

Question (2), If there is no such open source package I can use, how to create my own one? The only thing I can think of it's to use regular expression and join all the word phrases with 'or' in a regular expression. but I have 3000 phrases, I think it won't work in term of performance and filter every comment post. any suggestions where should I start from?

Thank you very much for your help and time.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

溺深海 2024-09-09 08:51:41

您可能需要查看 PROFANITIES_LIST 设置,看起来就像您可以将它与 验证器 一起使用。

尽管如此,有了这么多(真的有 3000 个吗?你一定在聚会上很有趣)的短语,你想要重新思考事情。您不应该过滤垃圾邮件。你应该把它扔掉。只是我的意见。如果评论中有垃圾邮件,为什么还要保留它呢?这样的评论有什么附加值吗?

You may want to check out the PROFANITIES_LIST setting, looks like you can use it with validators.

Although, with that many (3000 really? you must be fun at parties) phrases you want to rethink things. You shouldn't filter SPAM. You should throw it away. Just my opinion. If the comment has SPAM in it, why keep it at all? Is there any value added from such a comment?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文