RE: root rule question

Jim,

Answers below...

> -----Original Message-----
> From: www-voice-request@w3.org [mailto:www-voice-request@w3.org]On
> Behalf Of Jim Van Sciver
> Sent: Thursday, March 14, 2002 4:45 PM
> To: www-voice@w3.org
> Subject: 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?

Also in 4.1.4: "It is an error to reference a grammar by its root if that 
grammar does not declare a legal root rule."

This means that to reference a grammar without a root rule you must explicitly
reference one of its public rules.

Historical note: in the January 2001 Last Call Working Draft of SRGS the
root was defined as being either explicit or the disjunction of all public
rules contained in the grammar.  This behavior was determined to have to
many unexpected side-effects.  [Based on the section numbering it looks
like you're reading the August 2001 Last Call draft -- the latest one.]

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

Since the second grammar does not explicitly declare a root rule it
cannot be referenced as if by root.  So, the disjunction will not apply.

Note: neither grammar declares any public rule so external reference
is not possible in any case.

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

The private/public distinction does not affect the behavior in the
case that no root rule is declared.

Note: it is possible for the declared root rule to be private -- this
is the only exception to the behavior that a rule must be scoped public
to be externally visible.

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

We did discuss your first proposal and decided that idiosyncratic
handling of root depending upon the number of rules would be a
confusing precedent to set.

On the second point the specification makes a distinction between
activiating a grammar and activating a rule of a grammar -- with the
second being the adopted style.  For example, in VoiceXML a <grammar>
element references a *rule* and not a grammar.

<form>
  <field...>
    <!-- explicit reference to a rulename of a grammar -->
    <grammar src="http://example.com/grammar.grxml#rulename"/>

    <!-- implicit reference to the ROOT rule of a grammar -->
    <!-- this is illegal if the grammar does not specify a root -->
    <grammar src="http://example.com/grammar.grxml"/>

--Andrew Hunt
  Co-editor SRGS
  SpeechWorks

> Jim Van Sciver
> BBN Technologies
> Speech & Language Research
> 

Received on Friday, 15 March 2002 12:46:28 UTC