watson-conversationwatsonwatson-dialog

How to perform case-insensitive matching on Watson Dialog input.text


Good day Guys,

Please how can i perform case-insensitive matching on text that i read from the user input? i noticed that this code snippet

"context": {
         "number_extract": "<? input.text.extract('my name is ([\\w\\s\\w]*)', 1) ?>"
       }

will not match if the user enters My name is .......

Also please can anyone also suggest a good resource that i can use for using regular expression in the Dialog screen.

Thank you very much.


Solution

  • Watson conversation supports SPEL https://www.ibm.com/watson/developercloud/doc/conversation/expression-language.html

    For regex you can do

    input.text.matches( '[0-9]+' )
    

    I didnt check but you can probably do

    input.text.equalsIgnoreCase( 'xxxxx' )
    

    You can also do

    input.text.toUpperCase().matches(YOUR_REGEX)
    

    Finally You can use the following (?i) for case insensitivity. See https://blogs.oracle.com/xuemingshen/entry/case_insensitive_matching_in_java