解析电子邮件和 phone 数字实体?

Parsing email and phone number entities?

有没有一种方法可以训练 Watson 识别电子邮件实体和 phone 号码而不求助于正则表达式?

之前:

Steven, I had the same doubt a few months ago. IBM Watson Conversation doesn't have System entities for phone numbers or e-mail address, not yet. Anyway, it is a good idea for creating new System entities, right? We can give ideas with feedback for IBM.

But, one contour solution is to use context variables and create new entities. Try to create one entity like @mail, and add the values @gmail.com, @hotmail.com, @outlook.com, and any e-mail that you want to recognize.

And you will use with the condition like:

if @mail, response: Your e-mail is $email

for recognizing the e-mail address, but for saving the e-mail you will need to create one Regex inside the context variable like:

"email": "<? input.text.extract('[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+(\.[a-zA-Z]+){1,}',0)?>"

Now, for phone numbers:

You can activate the System Entity @sys-number, and you will get just a few numbers, like 11 numbers and save inside one context variable too.

Create one condition with @sys-number AND input.text.find('^[^\d]*[\d]{11}[^\d]*$',0)') for find the number and sys-number for recognize the numbers by user.

编辑:(带有新发行说明 - 在 BETA 版本中):

现在,IBM Watson Conversation 拥有实体模式,我们可以使用它来获取电子邮件地址、phone 号码等

现在,当你创建一个新的@entity时,你可以选择性地通知你想使用PatternSynonymous,因此,您将创建一个新实体,在我的示例中为 @contactInfo,并使用 patterns 的值来获取 mailphone 值,例如:

并且,在 Watson 训练您的更改后,检查在立即尝试中是否完美运行:

  • 邮件格式:\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b,例如 test@gmail.com
  • 美国手机模式:(\d{3})-(\d{3})-(\d{4}),例如800-426-4968

查看有关创建实体的更多信息here