首页 > 解决方案 > 具有 LUIS 意图的替代方法

问题描述

要求是从聊天窗口中给出的用户输入中捕获关键字,并进行 Web api 调用以获取文件链接。

我有四个不同的类别,用户输入查询可以分为:

--运营集团--技术--地理--主题

我已经配置了一个 LUIS 意图并将这四个类别列为实体。但是,现在的问题是无法预定义实体列表,因为可以将任意数量的搜索关键字传递给 web api。我现在很困惑是否有任何其他方法可以满足此要求,例如删除停用词并传递关键字 Web API 列表。

代码 :

           [LuisIntent("Credentials")]
    public async Task Credentials(IDialogContext context, LuisResult result)
    {
        try
        {                
            if (result.Entities.Count() == 0)
            {
                if ((result.Query.ToString().ToLower() == "geo" || result.Query.ToString().ToLower() == "operating group" || result.Query.ToString().ToLower() == "technology" || result.Query.ToString().ToLower() == "Themes"))
                {

                }
                else
                {
                    await context.Forward(new QnABotFeedbackDialog(updateQna, result.Query, rotationTemStorage, qnaInvalidMessageCount), AfterCredentialDialog, context.Activity, CancellationToken.None);
                }
            }
            else if (result.Entities.Count() > 0)
            {                    
                string efilterType = string.Empty;
                if (result.Entities.Count() > 0)
                {
                    foreach (var i in result.Entities)
                    {
                        if (efilterType == string.Empty)
                        {
                            efilterType = i.Entity;
                        }
                        else
                        {
                            efilterType = efilterType + "," + i.Entity;
                        }
                    }
                }
                await CredentialsPersonalisation(context, efilterType);
            }

        }
        catch (Exception ex)
        {
            await context.PostAsync(ex.Message);
        }

    }

标签: asp.net-web-apibotframeworkazure-language-understandingstop-words

解决方案


但是,我们没有可以在实体列表中预先配置的固定关键字集。

我想你误解了实体是什么。 Simple实体不是预先配置的列表,它会从您的话语和之后的调用中学习。所以这基本上是你想要的。因此,您必须简单地创建三个实体,然后添加话语并标记这些话语中的实体。不要对实体使用始终相同的值。

例如,添加以下话语:

give me the file for fs in North America region on RPA

并标记fsOperationGroup实体North America、实体GeographyRPA实体Technology

Can I have the file for PRD in Europe about LUIS?

并标记PRDOperationGroup实体Europe、实体GeographyLUIS实体Technology

旁注:如果您有固定列表,这里不是这种情况,您必须创建一个类型的实体List在此处输入图像描述


推荐阅读