Botframework findEntity() 问题
Botframework findEntity() issue
我遇到了一个奇怪的问题。最初我用这个来获取我的实体并且它工作正常。
x = builder.EntityRecognizer.findEntity(args.entities, 'get_x');
但是,出于某种原因,我似乎无法弄清楚为什么它停止工作,我不得不将其更改为添加一个额外的 intent
以使其再次工作。
x = builder.EntityRecognizer.findEntity(args.intent.entities, 'get_x');
当我认为这开始发生时,我正在改变我对 LUIS 的一个意图。然后我立即撤消对该意图的所有更改,但是我的所有意图都受到了某种影响,因为我需要向 findEntity()
方法的实体参数添加另一个 intent
。
我是否更改了某些可能导致此问题的内容?
编辑:实际上更改我的 LUIS 意图不应该影响它,因为我有另一个使用相同 LUIS 模型的机器人并且它仍在正常工作。
Edit2:我的 args
returns 我这个:
{ action: '*:SomeIntent',
intent:
{ score: 0.999846458,
intent: 'SomeIntent',
intents:
[ [Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object] ],
entities: [ [Object], [Object], [Object], [Object] ] },
libraryName: '*' }
最初我只能使用 args.entities
来查找我的实体,但现在格式改变了,我必须使用 args.intent.entities
来查找我的实体。
我找到了 this one uses args.entities
while this one 使用 args.intent.entities
的示例。我知道这并没有真正影响到我,因为我可以更改我的代码,但我很想知道为什么会这样?
谢谢。
您是否检查过机器人的 LuisRecognizers 的初始化并将它们相互比较?它们很可能在代码 BotBuilder-Sample/Node/intelligence-LUIS example uses only the botbuilder's LuisRecognizer on line 27 上略有不同。
var recognizer = new builder.LuisRecognizer(process.env.LUIS_MODEL_URL); // Line 27
bot.recognizer(recognizer);
bot.dialog('SearchHotels', [
function (session, args, next) {
...
var cityEntity = builder.EntityRecognizer.findEntity(args.intents.entities, 'builtin.geography.city');
如果仅使用 LuisRecognizer,则需要使用 args.intent.entities
而不是 args.entities
。
如果你使用 IntentDialog with LuisRecognizer, the setup is different in that you pass in var recognizer = new builder.LuisRecognizer(<model>)
to new builder.IntentDialog({ recognizers: [recognizer] })
. The object inside of IntentDialog is the only parameter it receives in its construction, and the optional property recognizers
takes an array of IIntentRecognizers (which is implemented by the LuisRecognizer).
下面的代码取自 Intent Dialog 文档的 Entity Recognition 部分(您的第一个示例):
var recognizer = new builder.LuisRecognizer('<your models url>');
var intents = new builder.IntentDialog({ recognizers: [recognizer] });
bot.dialog('/', intents);
intents.matches('AddTask', [
function (session, args, next) {
var task = builder.EntityRecognizer.findEntity(args.entities, 'TaskTitle');
if (!task) {
builder.Prompts.text(session, "What would you like to call the task?");
} else {
next({ response: task.entity });
}
},
...
]);
intents.matches()
将 pass the full details of the match 到意图匹配后的瀑布或对话中的第一步。但是,它将解析为 property/object 的意图,这意味着您不必使用 args.intent.entities
而只使用 args.entities
.
编辑:
Ah, that may have been it. For some reason I remember it working right after I changed it. Just wondering, are there any pros and cons between the two? Or just coding style that's different?
这不一定是优缺点,但这两种方法的区别在于,在第一种方法中,您只能合并一个 Luis 模型。 (见下文)
var mySingleRecognizer = new builder.LuisRecognizer(<model>);
bot.recognizer(mySingleRecognizer);
但是,如果您使用 IntentDialog({ recognizers: ... })
,您将能够传入一个识别器数组;例如多个 LUIS 模型...
var HotelRecognizer = new builder.LuisRecognizer(<HotelModel>);
var DogRecognizer = new builder.LuisRecognizer(<DogModel>);
甚至不同类型的识别器...
var RegularRecognizer = new builder.RegExpRecognizer('Cats', /^cat$/i);
进入您的 IntentDialog:
var intents = new builder.IntentDialog({ recognizers: [HotelRecognizer, DogRecognizer, RegularRecognizer] });
intents.matches('GetDog', [...]);
intents.matches('SearchHotels', [...]);
intents.matches('Cats', [...]);
我遇到了一个奇怪的问题。最初我用这个来获取我的实体并且它工作正常。
x = builder.EntityRecognizer.findEntity(args.entities, 'get_x');
但是,出于某种原因,我似乎无法弄清楚为什么它停止工作,我不得不将其更改为添加一个额外的 intent
以使其再次工作。
x = builder.EntityRecognizer.findEntity(args.intent.entities, 'get_x');
当我认为这开始发生时,我正在改变我对 LUIS 的一个意图。然后我立即撤消对该意图的所有更改,但是我的所有意图都受到了某种影响,因为我需要向 findEntity()
方法的实体参数添加另一个 intent
。
我是否更改了某些可能导致此问题的内容?
编辑:实际上更改我的 LUIS 意图不应该影响它,因为我有另一个使用相同 LUIS 模型的机器人并且它仍在正常工作。
Edit2:我的 args
returns 我这个:
{ action: '*:SomeIntent',
intent:
{ score: 0.999846458,
intent: 'SomeIntent',
intents:
[ [Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object] ],
entities: [ [Object], [Object], [Object], [Object] ] },
libraryName: '*' }
最初我只能使用 args.entities
来查找我的实体,但现在格式改变了,我必须使用 args.intent.entities
来查找我的实体。
我找到了 this one uses args.entities
while this one 使用 args.intent.entities
的示例。我知道这并没有真正影响到我,因为我可以更改我的代码,但我很想知道为什么会这样?
谢谢。
您是否检查过机器人的 LuisRecognizers 的初始化并将它们相互比较?它们很可能在代码 BotBuilder-Sample/Node/intelligence-LUIS example uses only the botbuilder's LuisRecognizer on line 27 上略有不同。
var recognizer = new builder.LuisRecognizer(process.env.LUIS_MODEL_URL); // Line 27
bot.recognizer(recognizer);
bot.dialog('SearchHotels', [
function (session, args, next) {
...
var cityEntity = builder.EntityRecognizer.findEntity(args.intents.entities, 'builtin.geography.city');
如果仅使用 LuisRecognizer,则需要使用 args.intent.entities
而不是 args.entities
。
如果你使用 IntentDialog with LuisRecognizer, the setup is different in that you pass in var recognizer = new builder.LuisRecognizer(<model>)
to new builder.IntentDialog({ recognizers: [recognizer] })
. The object inside of IntentDialog is the only parameter it receives in its construction, and the optional property recognizers
takes an array of IIntentRecognizers (which is implemented by the LuisRecognizer).
下面的代码取自 Intent Dialog 文档的 Entity Recognition 部分(您的第一个示例):
var recognizer = new builder.LuisRecognizer('<your models url>');
var intents = new builder.IntentDialog({ recognizers: [recognizer] });
bot.dialog('/', intents);
intents.matches('AddTask', [
function (session, args, next) {
var task = builder.EntityRecognizer.findEntity(args.entities, 'TaskTitle');
if (!task) {
builder.Prompts.text(session, "What would you like to call the task?");
} else {
next({ response: task.entity });
}
},
...
]);
intents.matches()
将 pass the full details of the match 到意图匹配后的瀑布或对话中的第一步。但是,它将解析为 property/object 的意图,这意味着您不必使用 args.intent.entities
而只使用 args.entities
.
编辑:
Ah, that may have been it. For some reason I remember it working right after I changed it. Just wondering, are there any pros and cons between the two? Or just coding style that's different?
这不一定是优缺点,但这两种方法的区别在于,在第一种方法中,您只能合并一个 Luis 模型。 (见下文)
var mySingleRecognizer = new builder.LuisRecognizer(<model>);
bot.recognizer(mySingleRecognizer);
但是,如果您使用 IntentDialog({ recognizers: ... })
,您将能够传入一个识别器数组;例如多个 LUIS 模型...
var HotelRecognizer = new builder.LuisRecognizer(<HotelModel>);
var DogRecognizer = new builder.LuisRecognizer(<DogModel>);
甚至不同类型的识别器...
var RegularRecognizer = new builder.RegExpRecognizer('Cats', /^cat$/i);
进入您的 IntentDialog:
var intents = new builder.IntentDialog({ recognizers: [HotelRecognizer, DogRecognizer, RegularRecognizer] });
intents.matches('GetDog', [...]);
intents.matches('SearchHotels', [...]);
intents.matches('Cats', [...]);