Reputation: 249
I'm learning about Microsoft's Bot Framework using LUIS. I'm trying to make a simple math bot that will understand math phrases. When the user types "what is two plus three" or anything similar, LUIS understands that the person wants to add two and three. The result is a LuisResult looks like this:
{
"query": "what is one plus three",
"topScoringIntent": {
"intent": "addition",
"score": 0.999997139
},
"intents": [
{
"intent": "addition",
"score": 0.999997139
},
{
"intent": "None",
"score": 0.03979478
}
],
"entities": [
{
"entity": "one",
"type": "builtin.number",
"startIndex": 8,
"endIndex": 10,
"resolution": {
"value": "1"
}
},
{
"entity": "three",
"type": "builtin.number",
"startIndex": 17,
"endIndex": 21,
"resolution": {
"value": "3"
}
}
]
}
I need to extract both of the "value" fields from the entities list. At the moment I only know how to extract the first entity "one" by doing
string numberResult = "";
EntityRecommendation rec;
if(result.TryFindEntity("builtin.number", out rec))
{
numberResult = rec.Entity;
this.number = Int32.Parse(numberResult);
}
Is there any way to extract both of the value fields "1" and "3" from this?
Upvotes: 1
Views: 1219
Reputation: 14787
LuisResult has a list of all the detected Entities. You can just iterate over them instead of using the TryFindEntity
method.
Upvotes: 2