如何在 express.js 中创建垃圾邮件过滤器或如何根据键值中的词过滤对象?
How create a spam filter in express.js or how to filter objects based on the word in the key values?
我想创建简单的垃圾邮件过滤器。我还没有收件箱,但我在想当收到电子邮件时,我可以发出 GET 请求并根据消息中提到的单词过滤对象。
如果发布的对象是
[{"id":"1" "email":"xyz@gmail.com", "cc": "abc@gmail.com",
"message": "You have a chance to win a lottery and be a millionaire"
},
{"id":"1" "email":"qwet@gmail.com", "cc": "ghj@gmail.com",
"message": "hello how are you doing" } ]
我要过滤消息中id===1且包含“lottery”、“win”、“millionaire”等词组合的对象
我遇到过朴素贝叶斯垃圾邮件过滤算法,但我不知道如何将它与 Express 集成。
感谢任何帮助。
你可以使用 filter()
posted_object.filter(
(item) => item.id != 1 || !item.message.includes("lottery") || !item.message.includes("win") || !item.message.includes("millionaire")
);
我想创建简单的垃圾邮件过滤器。我还没有收件箱,但我在想当收到电子邮件时,我可以发出 GET 请求并根据消息中提到的单词过滤对象。 如果发布的对象是
[{"id":"1" "email":"xyz@gmail.com", "cc": "abc@gmail.com",
"message": "You have a chance to win a lottery and be a millionaire" },{"id":"1" "email":"qwet@gmail.com", "cc": "ghj@gmail.com",
"message": "hello how are you doing" } ]
我要过滤消息中id===1且包含“lottery”、“win”、“millionaire”等词组合的对象
我遇到过朴素贝叶斯垃圾邮件过滤算法,但我不知道如何将它与 Express 集成。
感谢任何帮助。
你可以使用 filter()
posted_object.filter(
(item) => item.id != 1 || !item.message.includes("lottery") || !item.message.includes("win") || !item.message.includes("millionaire")
);