I want to create a node in the dialog that can detect airport_from and airport_to from a sentence:
"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:
{
"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.
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 :
<? 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 ?
, if false
the expression after the :
.
A simple way is to create 2 entities. "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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.