如何在LUIS和BOT框架中评估比今天更大的用户输入

时间:2017-09-14 19:12:51

标签: c# botframework luis

我正在使用C#和LUIS中的Microsoft Bot框架构建BOT。 使用预构建的实体datetime.V2,我能够正确地捕获“上周”,“下个月”等术语。 但是当涉及到时我很震惊:

 "Get me all products which has expiry life greater than 2 years",
 "greater than today",
 "> today" etc.,

我是否使用LUIS复合实体?如果是这样,“大于”和“今天”会成为名为“DateComparer”的复合实体的子项吗? 是否有任何github样本可以参考,以了解如何解析复合entites?

感谢您的帮助和提前的时间。

1 个答案:

答案 0 :(得分:0)

我根据Miskov的建议创建了一个ComparerList。

  "composites": [
    {
      "name": "DateComparer",
      "children": [
        "ComparerList",
        "datetimeV2"
      ]
    }
  ],
  "closedLists": [
    {
      "name": "ComparerList",
      "subLists": [
        {
          "canonicalForm": "gt",
          "list": [
            "greater than",
            "larger than",
            "more than",
            "over",
            "exceeding",
            "higher than",
            ">"
          ]
        },
        {
          "canonicalForm": "lt",
          "list": [
            "<",
            "less than"
          ]
        },
        {
          "canonicalForm": "eq",
          "list": [
            "=",
            "equal to"
          ]
        },
        {
          "canonicalForm": "le",
          "list": [
            "<=",
            "less than or equal to"
          ]
        },
        {
          "canonicalForm": "ge",
          "list": [
            ">=",
            "greater than or equal to"
          ]
        }
      ]
    }
  ],
  "bing_entities": [
    "datetimeV2"
  ],

我能够训练路易斯返回以下的json 像“给我所有物品的到期时间大于昨天”这样的话语。 我在测试时得到了以下json。

  "entities": [
    {
      "entity": "greater than",
      "type": "ComparerList",
      "startIndex": 33,
      "endIndex": 44,
      "resolution": {
        "values": [
          "gt"
        ]
      }
    },
    {
      "entity": "greater than yesterday",
      "type": "DateComparer",
      "startIndex": 33,
      "endIndex": 54,
      "score": 0.6950233
    },
    {
      "entity": "yesterday",
      "type": "builtin.datetimeV2.date",
      "startIndex": 46,
      "endIndex": 54,
      "resolution": {
        "values": [
          {
            "timex": "2017-09-14",
            "type": "date",
            "value": "2017-09-14"
          }
        ]
      }
    }

由此,我检索“gt”分辨率并在我的代码中使用它。