Luis 测试工具日期时间与本地解析的日期时间不同

Luis Test Tool Datetime different than Locally Resolved Datetime

我有一个为机器人技能创建的 Luis 模型。我正在为日期使用预建的 datetime 实体。

当我在 Luis 门户的测试工具上给出诸如 "Sell 5k [jargon] for this weekend at [jargon]" 之类的示例话语时,我得到了预期的响应(如下所示)。 timex 为 2020-W02-WE 并解析为 1/11 - 1/13。

请注意,对于下面的示例,我使用 "this weekend" 作为查询,但无论我是否输入与我的技能意图相匹配的话语,它都会解决同样的问题。 "this weekend" 用于示例中的简单性。

预计:

{
  "query": "this weekend",
  "prediction": {
    "normalizedQuery": "this weekend",
    "topIntent": "None",
    "intents": {
      "None": {
        "score": 0.8771556
      }
    },
    "entities": {
      "datetimeV2": [
        {
          "type": "daterange",
          "values": [
            {
              "timex": "2020-W02-WE",
              "start": "2020-01-11",  *** Saturday ***
              "end": "2020-01-13"     ***  Monday  ***
            }
          ]
        }
      ],
      "$instance": {
        "datetimeV2": [
          {
            "type": "builtin.datetimeV2.daterange",
            "text": "this weekend",
            "startIndex": 0,
            "length": 12,
            "modelTypeId": 2,
            "modelType": "Prebuilt Entity Extractor",
            "recognitionSources": [
              "model"
            ]
          }
        ]
      }
    }
  }
}

问题是,当我在本地使用相同的话语时,我得到的日期范围代表整个星期 1/6/2020 - 1/13/2020(星期一 - 星期一)。 Timex 是一样的;但是,当我解决它时,我得到了不同的价值。

Luis 使用话语对仿真器的响应 "this weekend":

{
  "recognizerResult": {
    "alteredText": null,
    "entities": {
      "$instance": {
        "datetime": [
          {
            "endIndex": 12,
            "startIndex": 0,
            "text": "this weekend",
            "type": "builtin.datetimeV2.daterange"
          }
        ]
      },
      "datetime": [
        {
          "timex": [
            "2020-W02-WE"
          ],
          "type": "daterange"
        }
      ]
    },
    "intents": {
      "None": {
        "score": 0.8771556
      }
    },
    "text": "this weekend"
  }
}
// 2020-W01-WE - This should resolve to weekend; doesn't work locally, works on Luis. 
Resolution resolution = 
  TimexResolver.Resolve(((List<string>)options.Entities.datetime[0].Expressions).ToArray());

var start = resolution.Values?[0].Start; // 01/06/2020
var end = resolution.Values?[0].End;     // 01/13/2020

关于我做错了什么以及我如何解决它有什么想法吗?

你是对的,这看起来确实应该有效。我认为这是 TimexResolver 中的一个错误,所以我编写了一个单元测试并向团队提交了一个 PR - 你可以看到它 here(具有讽刺意味的是它是 PR“2020”)。

如果您非常迫切需要此修复,您可以将 my copy of TimexResolver 拉入您自己的项目,并在我们等待 PR 被审查并希望被接受时重命名它(例如 TimexResolve2)。

[更新] PR 已经被接受并合并到 master 中(很快!)。您可以看到它 here - 现在我们只需要等待 Recognizers-Text 的下一个版本,或者暂时 download/clone 本地项目,关注 GH 上的版本