Botframework findEntity()问题 [英] Botframework findEntity() issue

查看:47
本文介绍了Botframework findEntity()问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个奇怪的问题.最初,我是用这个来获得实体的,并且可以正常工作.

I've encountered a strange problem. Originally I had this to get my entity and it works correctly.

x = builder.EntityRecognizer.findEntity(args.entities, 'get_x');

但是,由于某种原因,我似乎无法弄清原因,它停止了工作,我不得不将其更改为添加一个额外的intent才能使其再次工作.

However, for some reason I can't seem to figure out why, it stopped working and I had to change it to adding an additional intent to get it to work again.

x = builder.EntityRecognizer.findEntity(args.intent.entities, 'get_x');

当我认为这开始发生时,我正在改变我对LUIS的意图之一.然后,我立即撤消了对该意图的所有更改,但是我的所有意图都受到了某种影响,因为我需要在findEntity()方法的我的实体参数中添加另一个额外的intent.

I was changing one of my intents on LUIS when I think this started to happen. Then I immediately undo all the changes to that intent, however all my intents were somehow affected to that as I need to add another additional intent to my entities parameter of the findEntity() method.

我是否更改了某些可能导致此问题的内容?

Is there something that I changed that could have cause this?

实际上,更改我的LUIS意图不应该影响它,因为我有另一个使用相同LUIS模型的机器人,并且它仍然可以正常工作.

Actually changing my LUIS intents shouldn't have affected it as I've another bot using the same LUIS model and it's still working correctly.

Edit2:我的args将此返回给我:

My args returns me this:

{ 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来找到我的实体.

Originally I could just use args.entities to find my entity but now the format changed and I've to use args.intent.entities to find my entity.

我发现了此人使用args.entities这一个使用args.intent.entities.我知道这对我影响不大,因为我可以更改代码,但我很好奇为什么会这样?

I found examples where this one uses args.entities while this one uses args.intent.entities. I know this doesn't really affect me that much as I can just change my code but I'm curious to know why this happens?

谢谢.

推荐答案

您是否检查了机器人的LuisRecognizers的初始化并将它们相互比较?它们很可能在代码上稍有不同, BotBuilder-Sample/Node/intelligence-LUIS 示例仅使用botbuilder的第27行.

Have you checked the initialization of your bots' LuisRecognizers and compared them to each other? They most likely have a slight difference in code, the 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.

If only using the LuisRecognizer, you will need to use args.intent.entities instead of args.entities.

如果您将 IntentDialog 与LuisRecognizer一起使用,则设置区别在于您将var recognizer = new builder.LuisRecognizer(<model>)传递给new builder.IntentDialog({ recognizers: [recognizer] }). IntentDialog内部的对象是它在构造过程中接收到的唯一参数,并且可选属性recognizers采用一个

If you use 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).

以下代码摘自实体识别意图对话框"文档的部分(您的第一个示例):

The code below is taken from the Entity Recognition section of the Intent Dialog docs (your first example):

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()匹配意图后,将匹配的全部详细信息传递到瀑布或对话框的第一步.但是,它将解析为intent属性/对象,这意味着不必使用args.intent.entities,而只需使用args.entities.

intents.matches() will pass the full details of the match to the first step in the waterfall or dialog after an intent is matched. However, it will parse down to the intent property/object, meaning instead of having to use args.intent.entities you only use 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模型. (请参见下文)

It's not necessarily a pros-and-cons item, but the difference between the two methods is that in the first method you'll only be able to incorporate a single Luis model. (See below)

var mySingleRecognizer = new builder.LuisRecognizer(<model>);
bot.recognizer(mySingleRecognizer);

但是,如果您使用IntentDialog({ recognizers: ... }),则可以传递一系列识别器.例如多个LUIS模型...

However, if you use IntentDialog({ recognizers: ... }) you'll be able to pass in an array of recognizers; for example multiple LUIS models...

var HotelRecognizer = new builder.LuisRecognizer(<HotelModel>);
var DogRecognizer = new builder.LuisRecognizer(<DogModel>);

甚至不同类型的识别器...

Or even different types of recognizers...

var RegularRecognizer = new builder.RegExpRecognizer('Cats', /^cat$/i);

进入您的IntentDialog:

Into your IntentDialog:

var intents = new builder.IntentDialog({ recognizers: [HotelRecognizer, DogRecognizer, RegularRecognizer] });

intents.matches('GetDog', [...]);
intents.matches('SearchHotels', [...]);
intents.matches('Cats', [...]);

这篇关于Botframework findEntity()问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆