按给定顺序显示实体

时间:2018-08-22 07:36:38

标签: node.js python-3.x luis

以下是我的示例话语- 哪个产品在城市的销售中表现最好,而在整体销售方面却很差。我希望实体按发布顺序显示。

"entities": [
    {
      "entity": "city",
      "type": "entitylistgeographyrelated",
      "startIndex": 52,
      "endIndex": 55,
      "resolution": {
        "values": [
          "city"
        ]
      }
    },
    {
      "entity": "sales",
      "type": "entitylistmeasurevalues",
      "startIndex": 37,
      "endIndex": 41,
      "resolution": {
        "values": [
          "Sales $,amount"
        ]
      }
    },
    {
      "entity": "sales",
      "type": "entitylistmeasurevalues",
      "startIndex": 81,
      "endIndex": 85,
      "resolution": {
        "values": [
          "Sales $,amount"
        ]
      }
    },
    {
      "entity": "product",
      "type": "entitylistproductrelated",
      "startIndex": 6,
      "endIndex": 12,
      "resolution": {
        "values": [
          "product"
        ]
      }
    },
    {
      "entity": "best",
      "type": "entitymaximum",
      "startIndex": 65,
      "endIndex": 68,
      "score": 0.9999881
    },
    {
      "entity": "worst",
      "type": "entityminimum",
      "startIndex": 28,
      "endIndex": 32,
      "score": 0.9999083
    },
    {
      "entity": "product is performing worst at sales from",
      "type": "productgeocomposite",
      "startIndex": 6,
      "endIndex": 46,
      "score": 0.6175548
    }
  ],

(按给定的顺序),因此我很难确定产品或城市的最大销售额,仅此而已

1 个答案:

答案 0 :(得分:0)

LUIS不会更改JSON中实体的​​顺序。它们应该无关紧要。如果您依靠元素的顺序来确定用户所指的实体,那么我建议您重新考虑模型。

例如,以下话语:

  

“预订我从伦敦到巴黎的航班”

如果您有一个名为“城市”的实体,并且像这样标记实体,那么您做错了:

  

“预订我从{ city }到{ city }的航班”

这将不允许您知道哪个是原始城市,哪个是目标城市。要尝试依赖实体的顺序,这是一种非常脆弱的技术,可能会使您陷入困境。

在这种情况下,您应该有两个实体,一个用于原点,一个用于目的地,并相应地标记它们,如下所示:

  

“为我预订从{ originCity }到{ destinationCity }的航班”

通过这种方式,LUIS将根据您提供的训练话语,根据句子中实体的上下文来区分两个实体,并为您提供无需依赖即可使用的类型按照实体的顺序。