【问题标题】:Watson conversation list entity valueWatson 对话列表实体值
【发布时间】:2017-05-21 18:13:15
【问题描述】:

在 Watson Conversation 中,当我创建一个对话框时,我可以列出我的实体的值吗?对于示例,我有一个实体水果(苹果、橙子等),所以我可以在其中一个回复中列出 @fruits 的内容吗??

tks

【问题讨论】:

    标签: ibm-watson watson-conversation


    【解决方案1】:

    对于访问意图和实体,首先,你的用户需要请求一些东西来调用这个对象......在这种情况下,你的应用程序将访问:

    • 实体名称 (@fruits);
    • 用户输入的实体值

    如果您用户键入 orange,您的应用将显示 Fruit:orange,Watson 将识别实体和值并将其保存在 entities.fruit[0] 中,而不是 @fruits 中来自您的实体的所有值,例如 this

    访问实体:IBM官方Documentation

    无论如何:我认为你想要所有的价值观。对吧?

    我想最好的形式是使用context 变量来保存所有“水果”并显示如下:

    对于这个 Dialog 运行时上下文:

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

    更新:

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

    结果:

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

    为用户显示:

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

    所有 JSON 示例:

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

    结果:

    This is the array: lemon, orange, apple
    

    参见Official文档中的官方示例。

    【讨论】:

    • 但是我如何向我的用户展示这个?我知道如何创建和更新一个上下文变量,但我知道如何向我的用户列出数组的所有值。
    最近更新 更多