简体   繁体   中英

IBM Watson Assistant: Chatbot Entity Confusion over regular expression 2

I have created an entity called @material_number and this entity has 3 values which are provided below with their respective patterns:

num1 with the pattern (\\d{3}\\.){1}\\d{3}

num2 with the pattern (\\d{3}\\.){2}\\d{3}

num3 with the pattern (\\d{3}\\.){3}\\d{3}

In a dialogue node, if the bot recognizes @material_number it stores the provided user input under a context variable $materialnumber and then responds "Oh, the material number is $materialnumber".

The thing is that when the input of the user belongs to the value either num2 or num3 , the bot only stores the first 6 digits provided. For instance when the input is 123.123.123.123 or 123.123.123 , the bot only stores first six digits (seperated with a dot from the middle) and prompts back "Oh, the material number is 123.123".

By using JSON editor, it should be possible to overcome this confusion.

Similar to the solution suggested in this answer , you can nest ternary operators :

{
  "context": {
    "number1": "<? @number1:mat3 ? entities.number1[2].literal : @number1:mat2 ? entities.number1[1].literal : entities.number1[0].literal ?>"
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM