We've Moved! Please visit our new and improved forum over at our new portal: https://portal.plumvoice.com/hc/en-us/community/topics

Sample Grammar seems flawed

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
JumpTech
Posts: 5
Joined: Fri Nov 07, 2008 5:37 pm
Location: Minneapolis

Sample Grammar seems flawed

Post 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.

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

IVR code fix

Post 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
Last edited by support on Wed Feb 17, 2010 12:43 pm, edited 3 times in total.

JumpTech
Posts: 5
Joined: Fri Nov 07, 2008 5:37 pm
Location: Minneapolis

Post 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.

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

IVR code example in a SRGS+XML format

Post 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
Last edited by support on Mon Jan 11, 2010 12:42 pm, edited 2 times in total.

JumpTech
Posts: 5
Joined: Fri Nov 07, 2008 5:37 pm
Location: Minneapolis

srgs+xml grammar size

Post 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.

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

IVR grammar

Post 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

Post Reply