root rule question

I have a question about root rules in VoiceXML grammars that I'm hoping
someone can clear up.

Section 4.1.4 of the "Speech Recognition Grammar Specification" states that:
  "Both the XML and ABNF forms permit the grammar header to optionally
   declare a single rule to be the root rule of the grammar."

Absent a root rule are all rules in the grammar effectively an alternative?
If they are not equally weighted alternatives, then how does one distinguish
the top level rules?

Consider the following two grammars:

    <grammar version="1.0">
    <rule id="HelloWorld"> Hello World </rule>
    </grammar>

    <grammar version="1.0">
    <rule id="Hello"> Hello </rule>
    <rule id="HelloWorld"> <ruleref uri="#Hello"/> World </rule>
    </grammar>

The first clearly compiles to a single "Hello World" utterance.  What should
the second grammar compile to?  Most readers would say "Hello World" but
absent a root rule there is an equally strong argument for "Hello | Hello World".

It's possible that the ambiguity can be resolved via rule scoping:

    <grammar version="1.0">
    <rule id="Hello"      scope="private"> Hello </rule>
    <rule id="HelloWorld" scope="public"> <ruleref uri="#Hello"/> World </rule>
    </grammar>

but this seems awkward.  Things are still confusing if both rules
have public scope.

If my reading is correct, then please consider the following additions:
    - A root rule is optional for any grammar with a single rule.
    - A root rule is required for any grammar that is passed directly
      to a grammar processor.

Jim Van Sciver
BBN Technologies
Speech & Language Research

Received on Thursday, 14 March 2002 16:45:20 UTC