I\'m testing Watson Conversation API with a possible dialog my company wants to create. We are developing with Brazilian Portuguese. Given the portugues is a rich language and s
In this case, just for the complement and more bits of knowledge, a few days ago IBM Watson Conversation released a new Beta version for use Patterns.
With Patterns in @Entities, you can use regular expressions.
The Patterns field lets you define specific patterns for an entity value. A pattern must be entered as a regular expression in the field.
As in this example, for entity "ContactInfo", the patterns for phone, email values can be defined as follows:
Examples:
localPhone: (\d{3})-(\d{4})
, e.g. 426-4968
fullUSphone: (\d{3})-(\d{3})-(\d{4})
, e.g. 800-426-4968
email: \b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b
, e.g. test@gmail.com
Often when using pattern entities, it will be necessary to store the text that matches the pattern in a context variable (or action variable), from within your dialog tree.
Imagine a case where you are asking a user for their email address. The dialog node condition will contain a condition similar to @contactInfo:email
. In order to assign the user-entered email as a context variable, the following syntax can be used to capture the pattern match within the dialog node's response section:
{
"context" : {
"email": "@contactInfo.literal"
}
}
Obs.: The pattern matching engine employed by the Conversation service has some syntax limitations, which are necessary in order to avoid performance concerns which can occur when using other regular expression engines. Notably, entity patterns may not contain:
See more about Defining Entities in Watson Conversation (focused in step 7)