![](/img/trans.png)
[英]IBM Watson Assistant: What should be done if one entity value exist in multiple entities
[英]Watson Assistant Extract multiple pattern entities
我有一個實體定義為
@code
- @code:type_1 = pattern 'Y(\d{3})'
- @code:type_2 = pattern 'order number(\d{3})'
- @code:type_3 = pattern 'CZ(\d{3})'
我正在嘗試像這樣捕獲以下上下文值
{
"context": {
"type_3s": "<? @code.filter(\"c\", \"c['value'] == 'type_3'\").joinToArray('%e.groups[1]%') ?>"
}
}
所以對於輸入
Please delete codes CZ123, CZ456, and CZ789
,我的最終上下文如下所示: $type_3s =[123,456,789]
目前收到錯誤
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
在上面的示例中,code.values 的計算結果為:
@code.values =["type_3", "type_3", "type_3"]
非常感謝您在實現所需上下文方面的任何幫助,非常感謝!
我的建議是查看Watson Assistant 實體語法。 .value
返回標識的實體type_3 。 您需要使用.literal
來訪問真正輸入的內容。
在有關構建數據庫驅動的 Slackbot的教程中,使用類似的方法來訪問為位置實體輸入的內容。 代碼在 GitHub 上。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.