[英]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]
Please delete codes CZ123, CZ456, and CZ789
,我的最终上下文如下所示: $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 的计算结果为:
@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 .我的建议是查看Watson Assistant 实体语法。
.value
returns the identified entity which would be type_3 . .value
返回标识的实体type_3 。 You would need to use .literal
to access what was really entered.您需要使用
.literal
来访问真正输入的内容。
In the tutorial on building a database-driven Slackbot a similar method is used to access what was entered for a location entity.在有关构建数据库驱动的 Slackbot的教程中,使用类似的方法来访问为位置实体输入的内容。 The code is on GitHub.
代码在 GitHub 上。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.