问题描述
我正在查看此链接:
操作和参数|Dialogflow文档|Google Cloud
在解释列表参数"的地方,使用以下示例:
Where it explains 'List parameters' it uses these examples:
然后我想知道是否可以设置列表参数"来处理类似这样的事情:
Then I was wondering if it's possible to set up a 'List parameter' to handle something like this:
因此,您将拥有一种键-值"对列表.
So you'd have a sort of Key - Value pair list.
伪代码:
List<KeyValuePair<string, int>> fruitList = new List<KeyValuePair<string, int>>();
KeyValuePair<string, int> applesItem = new KeyValuePair<string, int>("apples", 7);
KeyValuePair<string, int> orangesItem = new KeyValuePair<string, int>("oranges", 8);
KeyValuePair<string, int> bananasItem = new KeyValuePair<string, int>("bananas", 12);
fruitList.Add(applesItem);
fruitList.Add(orangesItem);
fruitList.Add(bananasItem);
因此,在dialogflow中, $ FruitList
参数将类似于上面的键-值对列表 fruitList
.
So, in dialogflow, the $FruitList
parameter would be something like the Key - Value pair list fruitList
above.
然后,数字部分应与 @ sys.cardinal
实体匹配.并且水果部分应该与其中包含一堆水果的自定义实体 @Fruits
相匹配.
The number part should then match with the @sys.cardinal
entity. And the fruit part should match to a custom entity @Fruits
with a bunch of fruits in it.
伪代码: List< KeyValuePair< @ sys.cardinal,@ Fruits>>
我该如何在Dialogflow中创建一个意图"来做到这一点?有可能吗?
How can I make an 'Intent' in Dialogflow that can do this?Is it possible?
帮助/建议表示赞赏.
推荐答案
我不确定是否可以让dialogflow返回一个键值对对象,但是使用复合实体,您可以创建一个由数量(数字)和水果(水果实体).您可以调用此复合实体订单,并在意图中的参数中列出该列表.当您输入
Im not sure if you could get dialogflow return a key value pair object, but using composite entities you can create an entity which consists of an amount (number) and a fruit (fruit entity). You could call this composite entity order and make that a list in the parameters in your intent. When you enter
我要7个苹果,8个橙子和12个香蕉"
"I want 7 apples, 8 oranges and 12 bananas"
您应该获得包含3个订购实体的列表(7个苹果,8个橙子,12个香蕉)
You should get a list with 3 order entities ( 7 apples, 8 oranges, 12 bananas)
https://cloud.google.com/dialogflow/docs/entities-developer#developer_composite
这篇关于如何在Dialogflow中设置复杂的"IsList"参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!