英文:
Luis Test Tool Datetime different than Locally Resolved Datetime
问题
以下是翻译好的内容:
Luis模型创建用于机器人技能。我正在使用预建的datetime
实体来处理日期。
当我在Luis门户的测试工具中提供示例话语,比如“在这个周末卖5千[jargon]到[jargon]”,我得到了我期望的响应(如下所示)。Timex是2020-W02-WE
,解析为1/11 - 1/13。
请注意,对于下面的示例,我使用“这个周末”作为查询,但无论我输入与我的技能意图匹配的话语还是其他的,解析结果都是一样的。在示例中,我之所以使用“这个周末”,只是为了简单起见。
期望的响应:
{
"query": "这个周末",
"prediction": {
"normalizedQuery": "这个周末",
"topIntent": "None",
"intents": {
"None": {
"score": 0.8771556
}
},
"entities": {
"datetimeV2": [
{
"type": "daterange",
"values": [
{
"timex": "2020-W02-WE",
"start": "2020-01-11", *** 星期六 ***
"end": "2020-01-13" *** 星期一 ***
}
]
}
],
"$instance": {
"datetimeV2": [
{
"type": "builtin.datetimeV2.daterange",
"text": "这个周末",
"startIndex": 0,
"length": 12,
"modelTypeId": 2,
"modelType": "Prebuilt Entity Extractor",
"recognitionSources": [
"model"
]
}
]
}
}
}
}
问题在于当我在本地使用相同的话语时,我得到的日期范围表示整个周(2020/01/06 - 2020/01/13,星期一到星期一)。Timex相同,但是当我解析它时,得到了不同的值。
Luis对Emulator使用话语“这个周末”的响应:
{
"recognizerResult": {
"alteredText": null,
"entities": {
"$instance": {
"datetime": [
{
"endIndex": 12,
"startIndex": 0,
"text": "这个周末",
"type": "builtin.datetimeV2.daterange"
}
]
},
"datetime": [
{
"timex": [
"2020-W02-WE"
],
"type": "daterange"
}
]
},
"intents": {
"None": {
"score": 0.8771556
}
},
"text": "这个周末"
}
}
// 2020-W01-WE - 这应该解析为周末;在本地不起作用,在Luis上可以。
Resolution resolution =
TimexResolver.Resolve(((List<string>)options.Entities.datetime[0].Expressions).ToArray());
var start = resolution.Values?[0].Start; // 2020/01/06
var end = resolution.Values?[0].End; // 2020/01/13
关于我解析方式有什么问题,有什么想法吗?
英文:
I have a Luis model created for a bot skill. I'm using the prebuilt datetime
entity for dates.
When I give sample utterance such as "Sell 5k [jargon] for this weekend at [jargon]" on the Luis portal's test tool, I get the response I expect (shown below). The timex is 2020-W02-WE
and resolves to 1/11 - 1/13.
Note that for the example below, I used "this weekend" as the query, but it resolves the same regardless of whether I enter an utterance that matches my skill intent. "this weekend" was used for simplicity in the example.
Expected:
{
"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"
]
}
]
}
}
}
}
The problem is that when I use the same utterance locally, I'm getting a date range representing the whole week 1/6/2020 - 1/13/2020 (Monday - Monday). The Timex is the same; however, when I resolve it, I'm getting a different value.
Luis Response to Emulator using utterance "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
Any ideas on what I'm doing wrong with how I'm resolving it?
答案1
得分: 3
你说得对,这看起来肯定应该可以工作。我认为这是TimexResolver中的一个bug,所以我编写了一个单元测试并向团队提交了一个PR - 你可以在这里看到它(具有讽刺意味的是它是PR“2020”)。
如果你非常迫切需要这个修复,你可以将我的TimexResolver副本拉到你自己的项目中,并将其重命名(例如TimexResolve2),在等待PR被审查和希望被接受的时候使用。
[更新] PR已经被接受并合并到主分支(速度很快!)。你可以在这里看到它 - 现在我们只需要等待Recognizers-Text的下一个发布版本,或者暂时在GH上下载/克隆项目,然后等待发布。
英文:
You're right, this looks like it certainly should work. I think it's a bug in the TimexResolver, so I've written a unit test and submitted a PR to the team - you can see it here (ironically it's PR "2020").
If you need this fix super urgently, you can pull my copy of TimexResolver into your own project, and rename it (e.g. TimexResolve2) while we wait for the PR to be reviewed and hopefully accepted.
[Update] The PR was already been accepted and merged into master (that was quick!). You can see it here - now we just need to wait for the next release of Recognizers-Text, or just download/clone the project locally for now, an watch for releases on GH
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论