简体   繁体   中英

Watson Assistant Extract multiple pattern entities

I have an entity defined as

@code
- @code:type_1 = pattern 'Y(\d{3})'
- @code:type_2 = pattern 'order number(\d{3})'
- @code:type_3 = pattern 'CZ(\d{3})'

I am trying to capture the following context values like so

{
  "context": {
    "type_3s": "<? @code.filter(\"c\", \"c['value'] == 'type_3'\").joinToArray('%e.groups[1]%') ?>"
  }
}

So that for input

Please delete codes CZ123, CZ456, and CZ789 , my final context looks like this: $type_3s =[123,456,789]

Currently getting the error

SpEL evaluation error: Expression [ entities['code'].filter("c", "c['value'] == 'type_3'").joinToArray('%e.groups[1]%') ] at position 63: EL1004E: Method call: Method joinToArray(String) cannot be found on ArrayList type

In the above example, code.values evaluates to:

@code.values =["type_3", "type_3", "type_3"]

Any help in achieving the desired context would be greatly appreciated, thank you so much!

My recommendation would be to take a look at the Watson Assistant entity syntax . .value returns the identified entity which would be type_3 . You would need to use .literal to access what was really entered.

In the tutorial on building a database-driven Slackbot a similar method is used to access what was entered for a location entity. The code is on GitHub.

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