[英]Order of returned entities in IBM Watson Conversation service
我想在对话框中创建一个节点,该节点可以从句子中检测airport_from和airport_to :
"I want to go from Paris Orly to London heathrow"
这应该给我两个值London Heathrow
和Paris Orly
London Heathrow
,作为实体@airport
使用这样的索引:
{
"context": {
"from": "@airport[0]",
"to": "@airport[1]"
},
"output": {
"text": {
"values": [
"you are going from @airport[0] to @airport[1]"
],
"selection_policy": "sequential"
}
}
}
通常,您将拥有:
@airport[0] = 'Paris Orly'
@airport[1] = 'London Heathrow'
那很好,但是问题是当您反转两个机场时,您得到的结果与以前完全相同(即@airport[0] = 'Paris Orly'
),而不是相反的结果。
我需要的是使这些实体与句子中的实体顺序相同。 大家有什么想法吗?
您可以在响应中使用三元运算符 。 它链接到Watson Conversation表达式语言 :
<? entities['airport'][0].location[0]<entities['airport'][1].location[0] ?
'First, then second' : 'Second comes first' ?>
上面的方法计算第一个表达式,如果为true
,则使用?
之后的表达式?
如果false
后的表达:
。
一种简单的方法是创建2个实体。 在“从城市”和“到城市”中添加相同的值,例如在“从城市”中添加伦敦,从纽约和在“到城市”中添加到伦敦,纽约。 这是一个更好的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.