C# 获取LUIS的查询结果
我创建了一个LUIS帐户,并做了所有需要的事情 我已经编写了以下代码,并从LUIS那里得到了结果 我需要知道如何将查询结果保存到一个变量中,我希望使用该变量搜索数据库或web 下面是代码。。 这是查询结果C# 获取LUIS的查询结果,c#,json,azure-language-understanding,azure-cognitive-services,C#,Json,Azure Language Understanding,Azure Cognitive Services,我创建了一个LUIS帐户,并做了所有需要的事情 我已经编写了以下代码,并从LUIS那里得到了结果 我需要知道如何将查询结果保存到一个变量中,我希望使用该变量搜索数据库或web 下面是代码。。 这是查询结果 { "query": "the best resturant in Paris", "topScoringIntent": { "intent": "city", "score": 0.436210483 }, "entities": [ {
{
"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",
一个变量。请指导我,因为我对路易斯女士来说是全新的
例如:
string result=“paris”///该值应取自luis查询
string type=“city”/luis query的值应该取哪个一个选项是将NuGet包引用到您的项目中 然后您可以创建两个类(可以随意更改名称)
还有一个问题,如果查询中有多个实体。 怎么才能做到呢
只希望结果保存在变量中。谢谢,回答得很好,这就是我想要的。还有一个问题,如果查询中有多个实体。怎么才能做到呢?
"entity": "paris",
"type": "city",
public class LuisExtractionLuisResult
{
public List<LuisEntity> entities { get; set; }
}
public class LuisEntity
{
public string entity { get; set; }
public string type { get; set; }
}
var target = JsonConvert.DeserializeObject<LuisExtractionLuisResult>(strResponseContent);
string result = target.entities[0].entity;
string type = target.entities[0].type;
foreach(LuisEntity oneEntity in target.entities)
{
string result oneEntity.entity;
string type = oneEntity.type;
}