VoiceXML 2.1 Development Guide Home  |  Frameset Home

  Universal Grammars  |  TOC  |  DTMF Grammars in the GSL Format  

Grammar Slots

Note: GSL syntax is not considered to be a W3C-compliant syntax for grammars, and the Nuance has discontinued support for GSL grammars in their most recent product offerings. Voxeo will continue to support GSL-specific markup for some time to come, but it is strongly suggested that new applications and their associated grammars leverage the SRGS + SISR grammar syntaxes instead of being reliant upon the deprecated GSL grammar format.

The grammar slotnames, if not explicitly defined in the originating <field>, will default to the fieldname itself. The use of grammar slots comes in handy when we want to reuse a grammar in more than one <field>,  as evidenced in the example below:

GrammarSlot.vxml

<?xml version="1.0"?>

<vxml version="2.0">
  <form>

    <field name="F_1" slot="MySlot">
      <grammar src="GrammarFile.gsl#MYRULE" type="text/gsl"/>
      <prompt>
        what is your favorite cheese?
      </prompt>

        <filled namelist="F_1$.interpretation.MySlot">
        <prompt>
          You said <value expr="F_1$.interpretation.MySlot"/>
        </prompt>
          <goto nextitem="F_2"/>
        </filled>

    </field>

    <field name="F_2" slot="MySlot">
      <grammar src="GrammarFile.gsl#MYRULE" type="text/gsl"/>
      <prompt>
        what is your least favorite cheese?
      </prompt>

      <filled namelist="F_2$.interpretation.MySlot">
      <prompt>
        You said <value expr="F_2$.interpretation.MySlot"/>
      </prompt>
      </filled>

    </field>
  </form>
</vxml>



GrammarFile.gsl

MYRULE    [
[cheddar]                            {<MySlot "cheddar">}
(?monteray jack)                    {<MySlot "jack">}
(+stinky french cheese)            {<MySlot "stinky">}
                ]




  ANNOTATIONS: EXISTING POSTS
declanh
1/29/2010 10:19 AM (EST)
Hi,
In the field element you can specify the slot to use from the grammar. Can you specify more than one?
If you have a multi slot grammar do you have to use the individual specified slot from the application.lastresult$ array (Read it directly in the filled)?
Example:
<field name="AlphaNum_201" modal="true" cond="AlphaNum_201_Active" slot="confirm">
<if cond="dialog.AlphaNum_201$.interpretation == 'yes'">
OR
<if cond="application.lastresult$[0].interpretation.confirm == 'yes'">

For example, with these three, if you did not specify the slot as a field attribute, which slot will be used? The first returned?

application.lastresult$.interpretation.number
application.lastresult$.interpretation.date
application.lastresult$.interpretation.confirm
<assign name="AlphaNum" expr="dialog.AlphaNum_201$.interpretation"/>
what would you expect to see in the AlphaNum variable? All the slots, or just the first? (Assuming no slot specified)
Any comments appreciated!
Thanks,
Declan
voxeoblehn
1/29/2010 10:37 AM (EST)
Hello Declan,

Just wanted to update you quickly and let you know we are in the process of putting together some additional information for you on this. We look to have an additional update for you shortly, kindly stay tuned.

Regards,

Brian Lehnen
Voxeo Support
VoxeoDustin
1/29/2010 12:45 PM (EST)
Declan,

The slot attribute of the field element is unnecessary, but will determine the default slot to use with lastresult$.interpreation. When your grammar contains multiple slots, the lastresult$.interpretation variable will be an object with properties equivalent to each slot name. If you specify multiple slots, the value of lastresult$.interpretation - or fieldname$.interpretation, will be returned as "Object".

Let me know if we can be of further assistance.

Regards,
Dustin Hayre
Solutions Engineer
Voxeo Corporation
declanh
1/29/2010 1:25 PM (EST)
Hi Dustin,
Thanks.
Is there a way to get the names of the properties (That is, the slotnames)? That would be very useful.
Thanks again,
Declan
MattHenry
1/29/2010 2:34 PM (EST)
Helklo Declan,


I think the best way to answer this inquiry is with a code sample that illustrates how you can get at these slot values themselves, which can be found [url=http://www.vxml.org/gslmultislot.htm]right here[/url].

In regards to determining which slots are present in an arbitrary fashion, I'd suggest that you set the following in your <filled> element:

[code]<assign name="myObj" expr="application.lastresult$"/>
      <log expr="'*******' + JSON.stringify(myObj)"/>
[/code]

This will give you the "raw" values of the lastresult Object, which you can then access independently by crafting a foreach loop either via ECMAScript, or via the <foreach> VXML element.

Cheers,

~Matthew Henry

login
  Universal Grammars  |  TOC  |  DTMF Grammars in the GSL Format  

© 2012 Voxeo Corporation  |  Voxeo IVR  |  VoiceXML & CCXML IVR Developer Site