How to capture the multiple values of one entity in IBM watson assistant after asking slot?

拥有回忆 提交于 2021-02-10 04:14:15

问题


In my Watson Assistant app, I want to capture the multiple entities in the context and also have a slot to ask a question to user. Here is an example:

  • User: I want to fly from Toronto to Boston

And the Watson correctly detects:

intent: 'booking', @city:'Toronto', @city:'Boston'

Now I have a slot which asks for booking class:

  • Watson(Slot): Which class would you like?
  • User: Economy

At this point, the context only have first value for the @city entity i.e. Toronto. I understand from my googling that I can access @city[0] and @city1. And I tried to capture it in the context by doing the following but the value I'm getting is None.

How can I correctly capture both cities @city:Toronto, @city:Boston and at the same time entity @class:economy ?


回答1:


The slots are smart - when there are multiple entities of the same type and more slots that match the entity of the same type then when a slot matches the first entity it will be "eaten" and not available for other slot - hence the next slot matching the same entity type will match any other entity of the same type. To achieve what you want to do simply define the slots in a following way (so both of them match simply the @city entity).




回答2:


Revisiting this as there has been changes to Watson Assistant to make this easier.

1. Create two Entities. @fromCity and toCity.

2. Fill each entity with the same values. Names of locations.

3. Create your intent with questions like below.

I want to fly from Toronto to Boston
I have to get to Boston from Toronto ASAP. 
I want to get a flight to New York
I'm in Texas and need to fly to San Diego

4. On the intents page select each city and flag them as either the @fromCity or @toCity. This creates contextual entities.

Now when it trains it will understand the entities in the context of the sentence. It will also understand locations you have not trained it on.

More detailed example here.



来源:https://stackoverflow.com/questions/50072434/how-to-capture-the-multiple-values-of-one-entity-in-ibm-watson-assistant-after-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!