[英]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.