Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parsing email and phone number entities?

Is there a way to train Watson to recognize email entities and phone numbers without resorting to regular expresses?

like image 677
Steven Musumeche Avatar asked Jul 14 '17 00:07

Steven Musumeche


1 Answers

Previously:

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.

EDIT: (With new release notes - In BETA version):

Now, IBM Watson Conversation have Patterns for Entities and we can use for getting email address, phone numbers, etc.

Now, when you create one new @entity, you can optionally inform that you want to use Pattern or Synonymous, so, you will create one new entity, in my example, @contactInfo, and the values with patterns for getting the mail or phone values, for example:

enter image description here

And, after the Watson training your changes, check works perfectly in Try it Now:

enter image description here

  • Pattern for mail: \b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b, e.g [email protected]
  • Patter for USPhones: (\d{3})-(\d{3})-(\d{4}), e.g. 800-426-4968

See more about Creating entities here.

like image 100
Sayuri Mizuguchi Avatar answered Sep 20 '22 13:09

Sayuri Mizuguchi