在 Java 中检查一段文本是否为垃圾邮件的最佳、最简单、免费的方法是什么?

发布于 2024-08-26 19:11:06 字数 1539 浏览 4 评论 0原文

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

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

发布评论

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

评论(4

童话里做英雄 2024-09-02 19:11:06

这一点都不容易,需要有一些理论/数学/统计背景。它被称为贝叶斯过滤,它只是其中一种方法,但效果很好。

您可以在此处了解维基百科的介绍和一些背景知识,但这是一个被广泛涵盖的主题互联网上,随便搜索一下(我想也在 StackOverflow 上)。

It's not easy at all and requires to have some theoretical / mathematical / statistics background. It's called Bayesian filtering, it's just one of the methods but works great.

You can have an introduction and some background on wikipedia here, but it is a topic greatly covered over the internet, just search around (here on StackOverflow too I think).

£烟消云散 2024-09-02 19:11:06

也许最简单的方法是利用现有的 API。 Akismet 有Java 绑定,并且 WordPress 默认在其博客上使用它。哦,它是免费、自由、开源软件。

Probably the easiest way is to leverage an existing API for that. Akismet has bindings for Java, and it's what Wordpress uses on its blogs by default. Oh, and it's free, libre, open source software.

简单爱 2024-09-02 19:11:06

您可以通过 SpamAssassin 管道它并查看返回值是什么。

这里有一个古怪的想法:将文本作为电子邮件发送到 Gmail 帐户。然后使用 IMAP 查看它是否最终进入收件箱或垃圾邮件文件夹。

You could pipe it through SpamAssassin and see what the return value is.

Here's a wacky idea: send the text as an email to a Gmail account. Then use IMAP to see whether it ended up in the Inbox or the Spam folder.

甜扑 2024-09-02 19:11:06

Akismet 为您提供所有数学和逻辑,我认为这是避免垃圾邮件的最佳方法。

您只需索要与您的网站相关的密钥。有一种免费(自愿付费)的方式。

通过它的 Java API 的正常调用是这样的,我使用 commentCheck 对于您正在检查的那段文本。

Akismet akismet = new Akismet(AKISMET_KEY, SITE);
    return akismet.commentCheck(
        request.getRemoteAddr(),
        request.getHeader("User-agent"),
        request.getHeader("referer"),
        "", //permalink
        "comment", //comment type
        "", //author
        "", //email
        "",
        commentText, //Text to check
        request.getParameterMap());

如果此调用返回 true,则被视为垃圾邮件。

Akismet makes all that mathematical and logic for you, I think is the best way to avoid spam.

You only need to ask for you key related to your website. There's a free (voluntary paid) way.

A normal call through it's Java API would be like this, I use commentCheck for that piece of text you're checking.

Akismet akismet = new Akismet(AKISMET_KEY, SITE);
    return akismet.commentCheck(
        request.getRemoteAddr(),
        request.getHeader("User-agent"),
        request.getHeader("referer"),
        "", //permalink
        "comment", //comment type
        "", //author
        "", //email
        "",
        commentText, //Text to check
        request.getParameterMap());

If this call returns true, it's considered spam.

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