我有一个名为 result 的 LuisResult 变量,它具有类似
的 JSON 信息{
"query": "what is twenty * three",
"topScoringIntent": {
"intent": "Multiplication",
"score": 0.740870655
},
"intents": [
{
"intent": "Multiplication",
"score": 0.740870655
},
{
"intent": "Subtraction",
"score": 0.04339512
},
{
"intent": "None",
"score": 0.0164503977
},
{
"intent": "addition",
"score": 0.0126439808
},
{
"intent": "Division",
"score": 0.0108866822
}
],
"entities": [
{
"entity": "twenty",
"type": "builtin.number",
"startIndex": 8,
"endIndex": 13,
"resolution": {
"value": "20"
}
},
{
"entity": "three",
"type": "builtin.number",
"startIndex": 17,
"endIndex": 21,
"resolution": {
"value": "3"
}
}
]
}
我正在尝试访问“分辨率”下的“值”字段,因为它将数字的字符串表示形式转换为数字表示形式。目前我只是想获得第一个值。我试过用这种方式提取值(value)
var valuesEntity = result.Entities; //IList of all entities
string s = "";
s = valuesEntity[i].Resolution.Values.ToString(); //extract value field??
await context.PostAsync($"{s}"); //post to emulator
这会打印出 System.Collections.Generic.Dictionary`2+ValueCollection[System.String,System.String]
给我。我缺少什么才能获得“值”字段?
最佳答案
尝试
valuesEntity[i].Resolution.Values[0].ToString();
Values
是字符串的集合。
关于c# - 解析 LuisResult 以获取值字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42984395/