Certified Tech Tip: Multi-slot SISR subgrammars with Prophecy 8
Monday, February 11th, 2008
For our last certified tech-tip, we explored the older SISR-formatted returns that one can use when designing a recognition grammar for a VoiceXML application. For this week, we will tackle two different things related to SISR grammars when using the Prophecy 8 software:1 - How to use the newer SISR “.out” grammar return syntax2 - How we can craft a subgrammar returning multiple slot valuesIt would seem as if the second item is pretty elementary, but it does bear a little bit of illustration, especially in terms of how the values in the sub-rules will bubble up to the top-level return. For the sake of simplicity, we will do a much-simplified month/day grammar that contains a single entry. One you grasp the syntax, you can easily flesh this out more fully to include all possible months & days, or even overhaul it into a first-name & last-name grammar.Let’s take a peek at the grammar file itself, and then look at the relevant working parts:
<?xml version= “1.0″?>
<!DOCTYPE grammar PUBLIC “-//W3C//DTD GRAMMAR 1.0//EN” “http://www.w3.org/TR/speech-grammar/grammar.dtd”>
<grammar mode=”voice” xmlns=”http://www.w3.org/2001/06/grammar” xml:lang=”en-US” version=”1.0″ root=”TOPLEVEL” tag-format=”semantics/1.0″>
<rule id=”TOPLEVEL”>
<one-of>
<item>
<item>
<ruleref uri=”#MONTH”/> <tag>out.monthslot=rules.MONTH.monthsubslot;</tag>
</item>
<item>
<ruleref uri=”#DAY”/> <tag>out.dayslot=rules.DAY.daysubslot;</tag>
</item>
<tag>out.yearslot=”2008″;</tag>
</item>
</one-of>
</rule>
<rule id=”MONTH”>
<one-of>
<item> january <tag> out.monthsubslot=”January “;</tag> </item>
</one-of>
</rule>
<rule id=”DAY”>
<one-of>
<item> first <tag> out.daysubslot=”first”;</tag> </item>
</one-of>
</rule>
</grammar>
The grammar above consists of two sub-rules titled “MONTH” and “DATE”, and we have a single top-level rule titled “TOPLEVEL”. The sub-rules each specify a month and day slot respectively, and these slots will bubble up to the to-level when we invoke the syntax that we have below:
<ruleref uri=”#SUBRULE”> <tag>out.slotname.SUBRULENAME.subslot;</tag>
And we then reference these various slots within the VoiceXML as follows:
<log expr=”‘*** SLOT RESULT = ‘ + lastresult$.interpretation.slotname”/>
We also threw in a quick example of using the “out” syntax in a more generic manner for our “yearslot” value. In this case, it simply allows us to return a year value back to the VoiceXML from the top-level rule as opposed to having to reference the sub-rule values.This is added in to show how a “flat-file” non subgrammar can return a slot value using the newer SISR syntax that follows this format:
<tag>out.slotname;</tag>
So when using our month/day grammar above, one might still be unclear on how we get at all these slot values within the VoiceXML dialog. Once recognition has occurred, we would specify something like this:
<log expr=”‘*** YEAR RESULT = ‘ + lastresult$.interpretation.yearslot”/>
<log expr=”‘*** MONTH RESULT = ‘ + lastresult$.interpretation.monthslot”/>
<log expr=”‘*** DAY RESULT = ‘ + lastresult$.interpretation.dayslot”/>
Eventually, we will get around to creating some fully fleshed-out additions to our VoiceXML documentation on the subject of SISR grammars, but until then, we will post any cool tricks and tips here for the edification of our developers. As always, if heres anyone who’d like to see a posting, or techtip on a particular subject, just drop us a line, and we would be happy to accommodate.Next TechTip: Using SSML markup within a CallXML 3.0 application. Stay tuned to the blog; this next one is really cool.
~Matthew Henry
RSS Feed