【问题标题】:Microsoft Cognitive Services - Limit Intents in Luis ApiMicrosoft 认知服务 - 限制 Luis Api 中的意图
【发布时间】:2018-11-07 04:29:40
【问题描述】:

我们已经开始试验 Microsoft.CognitiveServices.Speech nuget 包 (https://docs.microsoft.com/en-gb/azure/cognitive-services/speech-service/how-to-recognize-intents-from-speech-csharp)。这很棒,因为它允许构建语言模型,并且您可以特别包含您想要匹配的意图:

    // 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");

但是,我们正在构建一个 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);
            }

有没有办法控制我们希望为特定文本字符串返回的意图?我们可以将 verbose 设置为 true,以便它返回具有匹配评级的所有意图,但我们希望能够根据状态指定意图的子集并尝试匹配这些意图。看来您可以通过使用音频的 SDK 来做到这一点,这可以使用文本来完成(是否有文本 SDK?)。

另外,有没有办法让 JSON 中返回的实体与填充它们的意图相匹配,看起来意图和实体之间没有链接。

【问题讨论】:

    标签: c# microsoft-cognitive azure-language-understanding azure-cognitive-services


    【解决方案1】:

    很遗憾,不,没有办法控制返回的意图。在应用程序中,您需要过滤返回的意图以限制与特定文本字符串匹配的内容。

    【讨论】:

      猜你喜欢
      • 2020-05-18
      • 2019-04-11
      • 2020-09-06
      • 2020-11-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-06
      • 2017-10-12
      相关资源
      最近更新 更多