0

我需要一种模式来处理传入的电子邮件。

我目前的伪代码是这样的:

if sender is a@a.com and messageBody contains "aaa" then
   extract the content according the aaa function
   save it to database
   move the message to the archive
else if messageBody contains "bbb" then
   extract the content according to bbb function
   save it to database
   inform sender
   move the message to archive
else if messageBody NOT contains "ccc" and from "sender@ccc.com" and then
   leave message in the inbox so the it will be manually processed
else if ...
   ...

所以,我最终得到了一个有数千行的猪函数。

我怎样才能让这件事变得更简单?

提前致谢

4

1 回答 1

0

解决这个问题需要一个非常好的架构,机器学习是这类问题的最佳解决方案之一。但是仍然有一些事情可以处理,以使其更简单。

  1. 与其为 10 个电子邮件 ID 放置 10 个 if,不如创建一个不需要的用户列表(这将进入垃圾邮件)

  2. 创建不需要的主题列表

  3. 创建时间间隔组并相应地处理电子邮件;早上的电子邮件,中午的电子邮件,晚上的电子邮件等

  4. 创建有附件检查

  5. 没有主题检查

  6. 没有身体检查

  7. 朋友的电子邮件列表

  8. 同域电子邮件 ID发件人检查

    谢谢。:)

于 2016-03-09T12:13:19.097 回答