[英]Order of returned entities in IBM Watson Conversation service
I want to create a node in the dialog that can detect airport_from and airport_to from a sentence: 我想在对话框中创建一个节点,该节点可以从句子中检测airport_from和airport_to :
"I want to go from Paris Orly to London heathrow"
This should give me both values London Heathrow
and Paris Orly
as an entity @airport
using the indexes like this: 这应该给我两个值
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"
}
}
}
Typicaly you would have: 通常,您将拥有:
@airport[0] = 'Paris Orly'
@airport[1] = 'London Heathrow'
That works fine, but the problem is when you invert the two airports you get exatly the same result as before (ie @airport[0] = 'Paris Orly'
) and not the inverse. 那很好,但是问题是当您反转两个机场时,您得到的结果与以前完全相同(即
@airport[0] = 'Paris Orly'
),而不是相反的结果。
What I need is getting these entities in the same order as they are in the sentence. 我需要的是使这些实体与句子中的实体顺序相同。 Any ideas folks ?
大家有什么想法吗?
You could use a ternary operator in the response. 您可以在响应中使用三元运算符 。 It is linked on the Watson Conversation expression language :
它链接到Watson Conversation表达式语言 :
<? entities['airport'][0].location[0]<entities['airport'][1].location[0] ?
'First, then second' : 'Second comes first' ?>
The above evaluates the first expression and if true
uses the expression after the ?
上面的方法计算第一个表达式,如果为
true
,则使用?
之后的表达式?
, if false
the expression after the :
. 如果
false
后的表达:
。
A simple way is to create 2 entities. 一种简单的方法是创建2个实体。 "From City" and "To City" and add same values in both like in "From City" add From London ,From Newyork and in "To City" add To London,To Newyork.
在“从城市”和“到城市”中添加相同的值,例如在“从城市”中添加伦敦,从纽约和在“到城市”中添加到伦敦,纽约。 This is a better way.
这是一个更好的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.