簡體   English   中英

IBM Watson Conversation服務中返回的實體的順序

[英]Order of returned entities in IBM Watson Conversation service

我想在對話框中創建一個節點,該節點可以從句子中檢測airport_fromairport_to

"I want to go from Paris Orly to London heathrow"

這應該給我兩個值London HeathrowParis 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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM