When Lexicon matches an intent at runtime it looks for an action associated with that intent and calls its Process method with a LexiconRuntimeResult. The LexiconRuntimeResult contains the following information:
Utterance | The phrase that was uttered by the user |
Intent | The intent that matched this utterance |
Confidence | Confidence score for the intent match, a value between 0 and 1 |
EntityMatches | The EntityMatches that were found in this utterance |
SpeechResult | The full speech-to-text result for this utterance |
LexiconRuntimeResult also contains a few helpful methods:
GetEntityMatch(string entityName) | Returns the first entity match for the given entity name |
GetEntityMatches(string entityName) | Returns all the entity matches for the given entity name |
GetEntityBefore(string entityName, LexiconEntityMatch targetMatch) | Returns the entity with the given entity name that appears before the target match |
GetEntityAfter(string entityName, LexiconEntityMatch targetMatch) | Returns the entity with the given entity name that appears after the target match |
Use these methods to parse an utterance that contains multiple parts. For example, if a user says “Create a red cube here and a blue sphere here”, we can use the following approach:
- Use
GetEntityMatches
to find all the primitives in the utterance - Loop over the primitive matches
- Use
GetEntityBefore
to find the color for the current primitive - Use
GetEntityAfter
to find the position for the current primitive
- Use