简体   繁体   English

Microsoft认知服务-Luis Api中的限制意图

[英]Microsoft Cognitive Services - Limit Intents in Luis Api

We have started experimenting with the Microsoft.CognitiveServices.Speech nuget package ( https://docs.microsoft.com/en-gb/azure/cognitive-services/speech-service/how-to-recognize-intents-from-speech-csharp ). 我们已经开始尝试使用Microsoft.CognitiveServices.Speech nuget包( https://docs.microsoft.com/en-gb/azure/cognitive-services/speech-service/how-to-recognize-intents-from-speech- csharp )。 This is great as it allows a language model to be built up and you can specifically include the intents you want to be matched: 这很棒,因为它允许建立语言模型,并且您可以专门包括要匹配的意图:

    // Creates a Language Understanding model using the app id, and adds specific intents from your model
    var model = LanguageUnderstandingModel.FromAppId("YourLanguageUnderstandingAppId");
    recognizer.AddIntent(model, "YourLanguageUnderstandingIntentName1", "id1");
    recognizer.AddIntent(model, "YourLanguageUnderstandingIntentName2", "id2");
    recognizer.AddIntent(model, "YourLanguageUnderstandingIntentName3", "any-IntentId-here");

However, we are building an API and will be passing text over and this will call Luis using the API endpoint, this is very basic like so: 但是,我们正在构建一个API,并将传递文本,这将使用API​​端点调用Luis,这是非常基本的,如下所示:

using (var client = new HttpClient())
            {
                var queryString = HttpUtility.ParseQueryString(String.Empty);

                // The request header contains your subscription key
                client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", _cognitiveSettings.SubscriptionKey);

                // The "q" parameter contains the utterance to send to LUIS
                queryString["q"] = query;

                // These optional request parameters are set to their default values
                queryString["staging"] = _cognitiveSettings.IsProduction ? bool.FalseString : bool.TrueString;
                queryString["timezoneOffset"] = "0";
                queryString["verbose"] = "true";
                queryString["spellCheck"] = "false";

                var endpointUri = $"https://westeurope.api.cognitive.microsoft.com/luis/v2.0/apps/{_luisAppId}?{queryString}";
                var response = await client.GetAsync(endpointUri);

                var responseJson = await response.Content.ReadAsStringAsync();
                return JsonConvert.DeserializeObject<IntentResponseModel>(responseJson);
            }

Is there a way to control the intents we would want to be returned for a particular text string? 有没有一种方法可以控制我们希望针对特定文本字符串返回的意图? We can set verbose to true so it returns all intents with a match rating but we would prefer to be able to specify a subset of intents depending on the state and just try to match those. 我们可以将verbose设置为true,以便它返回所有具有匹配评级的意图,但是我们希望能够根据状态指定意图的子集,然后尝试进行匹配。 It seems you can do this with the SDK using audio, can this be done using text (is there a text SDK?). 看来您可以使用带音频的SDK来做到这一点,可以使用文本来实现(是否有文本SDK?)。

Also, is there a way for the entitites that are returned in the JSON to be matched to the intent which populated them, it looks like there is no link between the intents and the entities. 另外,是否有一种方法可以将在JSON中返回的实体与填充它们的意图进行匹配,似乎在意图和实体之间没有链接。

Unfortunately, no, there is no way to control the intents that are returned. 不幸的是,没有,没有办法控制返回的意图。 In the app, you will need to filter on the intents returned to limit what is matched for a particular text string. 在应用程序中,您将需要过滤返回的意图以限制与特定文本字符串匹配的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM