简体   繁体   English

Watson对话列表实体值

[英]Watson conversation list entity value

In Watson Conversation when I create a dialog, can I list the values of my Entity?? 在创建对话框的“ Watson对话”中,我可以列出我的实体的值吗? for sample I have one entity fruits (apple, orange, and etc) so in one of my responses can I list the content of @fruits?? 例如,我有一个实体水果(苹果,橘子等),因此我可以在其中之一中列出@fruits的内容吗?

tks ks

For access intents and entities, first, your user need to request something for calling this objects... And in this case, your application will access: 对于访问意图和实体,首先,您的用户需要请求一些东西来调用此对象……在这种情况下,您的应用程序将访问:

  • Name of entity (@fruits); 实体名称(@fruits);
  • The value of your entity typed from your user 从用户输入的实体值

Your app will show Fruit:orange if you user type orange, and Watson will recognize the entity and the value and save inside entities.fruit[0] , not all values from your entity inside @fruits, like this . 如果您输入橙色,您的应用程序将显示Fruit:orange,并且Watson会识别该实体和值,并保存在Entitys.fruit entities.fruit[0] ,而不是您的实体的所有值都在@fruits中,例如this

Access entity: IBM Official Documentation . 访问实体:IBM官方文档

Anyway : I think you want all values. 无论如何 :我认为您想要所有价值观。 Right? 对?

I guess that best form is using context variables to save all "fruits" and show like: 我猜最好的形式是使用context变量保存所有“水果”并显示如下:

For this Dialog runtime context: 对于此对话框运行时上下文:

{
  "context": {
    "toppings_array": ["orange", "apple"]
  }
}

Update: 更新:

{
  "context": {
    "toppings_array": "<? $toppings_array.append('banana', 'melon') ?>"
  }
}

Result: 结果:

{
  "context": {
    "toppings_array": ["orange", "apple", "banana", "melon"]
  }
}

Show for the user: 显示给用户:

{
  "output": {
    "text": "This is the array: <? $toppings_array.join(', ') ?>"
  }
}

All JSON Example: 所有JSON示例:

{
  "context": {
    "fruits": [
      "lemon",
      "orange",
      "apple"
    ]
  },
  "output": {
    "text": {
      "values": [
        "This is the array: <? $fruits.join(', ') ?>"
      ],
      "selection_policy": "sequential"
    }
  }
}

Result: 结果:

This is the array: lemon, orange, apple

在此处输入图片说明

See the official example from Official Documentation. 请参阅官方文档中的官方示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM