如何在API.AI(Dialogflow)中创建属性组合的列表 [英] How can I create a list of a combination of attributes in API.AI (Dialogflow)

查看:39
本文介绍了如何在API.AI(Dialogflow)中创建属性组合的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个要求,我想从API.AI接受2个属性的列表,例如,用户可以说以下任何内容:



add 2个橙子和3个香蕉2我的购物车



将2个橙子3个香蕉和5个苹果添加到我的购物车



所以它应该将计数和水果名称组合的列表发送到我的应用程序。有任何建议吗?

解决方案

您可以通过



您只需要一个值,没有同义词,它应该包含您要收集的两个参数:




  • @ sys.number-integer:number @ sys.number-integer 部分代表整数的系统实体,:number 部分是我们要给此参数提供的名称)


  • @fruit:fruit @fruit 部分是我们的水果实体的名称,:fruit 部分是我们将使用此参数的名称)




现在,当您添加示例时包含此格式的项目以达到目的,您将看到检测到新的复合实体:





但是,当前示例中的出现被视为两个单独的参数,而不是列表。要将这些实体视为与两个离散项目相对的列表,请选择第二个突出显示的示例,然后单击与第一个参数相对应的项目(在屏幕快照中,它是带有蓝色文字的 number-of -fruit ):





现在,您将看到参数部分指示此参数为列表:





保存并训练后,您可以通过控制台测试此方法是否适用于任意长度列表:




I have a requirement where I want to accept a list of 2 attributes from API.AI, for example, the user can say any of the following:

add 2 oranges and 3 bananas 2 my cart

add 2 oranges 3 bananas and 5 apples to my cart

So it should send a list of the combination of count and fruit-name to my application. Any suggestions?

解决方案

You can do this with Composite Entities.

First, create an entity that lists all of the fruit and their synonyms (let's call it fruit).

Then create a composite entity (let's call it number-of-fruit) that looks like this:

You just need one value, without synonyms, and it should contain the two parameters you wish to collect:

  • @sys.number-integer:number (the @sys.number-integer part represents the System Entity for integer, the :number part is the name we'll give this parameter)

  • @fruit:fruit (the @fruit part is the name of our fruit entity, the :fruit part is the name we'll give this parameter)

Now, when you add an example containing items in this format to an intent, you'll see that your new composite entity is detected:

However, the occurrences in the example are currently being treated as two separate parameters, not a list. To treat these entities as a list as opposed to two discrete items, select the second highlighted example and click the item that corresponds to the first parameter (in the screenshot it's the one with the blue text saying number-of-fruit):

Now, you'll see that the parameters section indicates that this parameter is a list:

Once you save and train, you can test that this works for an arbitrary length list via the console:

这篇关于如何在API.AI(Dialogflow)中创建属性组合的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆