我已经创建了一个 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 查询中获取哪个值
qq_花开花谢_0
相关分类