Contexts, the usage of open and grammar recognizers.

Grammars can be switched in the middle of a flow, allowing for more context specific grammars to be used. When asking a yes/no question it makes sense to look for a yes/no answer, but in a question in which the answer is expected to be a number the grammar for yes/no is less useful.

In this example, a context called "new_context" is loaded first as an OpenVocabularyContext and then as a SemanticGrammarContext before it is used in a listen command.

An SemanticGrammarContext will only parse the audio according to the rules described in the Grammar file. An OpenVocabularyContext on the other hand will parse the audio only through Furhat's current Recognizer.

By loading both into the same context, "new_context" , we are able to use the abilites of both. The text of the agent:listen will contain the full text parsed by the Recognizer, and the event will have semantics in accordance to the Grammar rules.

<var name="language" type="iristk.util.Language" value="new iristk.util.Language('en-US')"/>
<onentry>
  <send event="action.context.load" p:context="new iristk.speech.OpenVocabularyContext('new_context', language)" />
  <send event="action.contex.load" p:context="new iristk.speech.SemanticGrammarContext(new iristk.cfg.SRGSGrammar(getPackageFile('NewGrammar.xml')))" />
  <agent:listen context="'new_context'" />
</onentry>