Does watson conversation intents and entities support regular expressions?

前端 未结 3 1438
长情又很酷
长情又很酷 2021-01-22 06:04

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

3条回答
  •  天涯浪人
    2021-01-22 06:43

    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:

    • Positive repetitions (e.g., x*+)
    • Backreferences (e.g., \g1)
    • Conditional branches (e.g., (?(cond)true))

    See more about Defining Entities in Watson Conversation (focused in step 7)

提交回复
热议问题