【发布时间】:2018-08-31 08:32:12
【问题描述】:
我创建了一个 LUIS 帐户并完成了所需的一切。
我已经编写了以下代码,并从 LUIS 中得到了结果。
我需要知道如何将我的查询结果保存到一个变量中,我想使用它来搜索数据库或网络。
下面是代码..
static async void MakeRequest(string qz) {
var client = new HttpClient();
var queryString = HttpUtility.ParseQueryString(string.Empty);
var luisAppId = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
var endpointKey = "XXXXXXXXXXXX";
client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", endpointKey);
// The "q" parameter contains the utterance to send to LUIS
queryString["q"] = qz;
// These optional request parameters are set to their default values
queryString["timezoneOffset"] = "0";
queryString["verbose"] = "false";
queryString["spellCheck"] = "false";
queryString["staging"] = "false";
var endpointUri = "https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/" + luisAppId + "?" + queryString;
var response = await client.GetAsync(endpointUri.);
var strResponseContent = await response.Content.ReadAsStringAsync();
// Display the JSON result from LUIS
Console.WriteLine(strResponseContent.ToString());
}
这里也是查询结果。
{
"query": "the best resturant in Paris",
"topScoringIntent": {
"intent": "city",
"score": 0.436210483
},
"entities": [
{
"entity": "paris",
"type": "city",
"startIndex": 22,
"endIndex": 26,
"score": 0.7153605
}
]
}
现在我想保存这个
"entity": "paris",
"type": "city",
到一个变量。请指导我,因为我对 MS LUIS 完全陌生。
示例:
string result = "paris" /// 应该从 luis 查询中获取哪个值
string type = "city" /// 应该从 luis 查询中获取哪个值
【问题讨论】:
-
只想将结果保存在变量中。
标签: c# json azure-language-understanding azure-cognitive-services