Page 1 of 1
Sample Grammar seems flawed
Posted: Fri Nov 07, 2008 5:55 pm
by JumpTech
I am having some difficulty and am somewhat new to the various Grammars that exist out there.
I have tried to follow the Plum documentation on Grammars and they provide the following JSGF example, however it does not function as described.
In the following example it matches everything I say to {Turtle} when I need it to match the dog elements to Dog and the cat elements to Cat.
Also if I wanted to add an additional element for (Big Dog) does this need to be quoted?
<grammar type="application/x-jsgf">
([Puppy | Dog] {Dog} |
[Cat | Kitten | Kitty] {Cat} |
[Turtle | Tortoise] {Turtle})
</grammar>
Any advise? What am I not getting here?
Thanks in advance.
IVR code fix
Posted: Fri Nov 07, 2008 6:09 pm
by support
Hi,
Thanks for pointing this out to us. We will correct this flaw in the IVR documentation. The IVR grammar should look like this:
Code: Select all
<grammar type="application/x-jsgf">
(
((Puppy | Dog) {Dog}) |
((Cat | Kitten | Kitty) {Cat}) |
((Turtle | Tortoise) {Turtle})
)
</grammar>
Here is some sample IVR code you could use to test this out:
petgrammar.php
Code: Select all
<?php
header("Content-type: text/xml");
echo("<?xml version=\"1.0\"?>\n");
?>
<vxml version="2.0">
<form>
<field name="pet">
<grammar type="application/x-jsgf">
(
((Puppy | Dog) {Dog}) |
((Cat | Kitten | Kitty) {Cat}) |
((Turtle | Tortoise) {Turtle})
)
</grammar>
<prompt>
What pet do you want?
</prompt>
<filled>
<prompt>
You said <value expr="pet"/>.
</prompt>
</filled>
</field>
</form>
</vxml>
Note: Using JSGF grammars for examples such as this is good for small-sized grammars. However, for medium to large-sized grammars, you would want to use
SRGS+XML grammars as their performance is superior to
JSGF grammars.
Hope this helps.
Regards,
Plum Support
Posted: Fri Nov 07, 2008 6:57 pm
by JumpTech
Excellent this does work as described now. Thank you.
Can you please offer this exact same example in a srgs+xml format?
The SRGS format seems to be very wordy when attempting to match several equivalent options such as cat | kitten | kitty.
Thanks.
IVR code example in a SRGS+XML format
Posted: Mon Nov 10, 2008 10:27 am
by support
Hi,
Here is the same IVR code example in a
SRGS+XML format:
Code: Select all
<?php
header("Content-type: text/xml");
echo("<?xml version=\"1.0\"?>\n");
?>
<vxml version="2.0">
<form>
<field name="pet">
<grammar mode="voice" type="application/srgs+xml" root="petnames">
<rule id="petnames" scope="public">
<one-of>
<item>Dog <tag>pet='Dog'</tag></item>
<item>Puppy <tag>pet='Dog'</tag></item>
<item>Cat <tag>pet='Cat'</tag></item>
<item>Kitten <tag>pet='Cat'</tag></item>
<item>Kitty <tag>pet='Cat'</tag></item>
<item>Turtle <tag>pet='Turtle'</tag></item>
<item>Tortoise <tag>pet='Turtle'</tag></item>
</one-of></rule>
</grammar>
<prompt>
What pet do you want?
</prompt>
<filled>
<prompt>
You said <value expr="pet"/>.
</prompt>
</filled>
</field>
</form>
</vxml>
Hope this helps.
Regards,
Plum Support
srgs+xml grammar size
Posted: Mon Nov 10, 2008 11:26 am
by JumpTech
Awesome.
You mentioned these Grammars do load fast since there is less processing/pre-parsing required on startup.
Is there a limit on how large these srgs+xml grammars can get? They are much more wordy than the other varieties which support and/or logic in the contexts of the grammar.
Thanks as always.
IVR grammar
Posted: Mon Nov 10, 2008 11:57 am
by support
Hi,
Although SRGS+XML appear to be more wordy than other IVR grammar types, they do process and load faster.
As for a limit to how large these IVR
SRGS+XML grammars should be, we recommend that you limit it to a couple hundred entries for good quality performance. Beyond this, you should let us know and we will help you better implement your IVR grammar.
Regards,
Plum Support