An ABNF PrimerConcepts, structure, syntax
IntroductionW3C standard
http://www.w3.org/TR/speech-grammar
W3C recommandation:
March 16th, 2004
Defines both the XML form and the Augmented BNF (ABNF) form
They are equivalent
Supported by a complete development environment
NuGram IDECopyright © 2010 Nu Echo Inc.
Structure of an ABNF GrammarHeaders#ABNF 1.0 ISO-8859-1;language en-US;mode voice;root$yesOrNo;private$yesOrNo =   yes {out.value = 'yes'}| no  {out.value = 'no'};RulesCopyright © 2010 Nu Echo Inc.
CommentsC/C++/Java Comments
// to end of line
/* ... */
Documentation comments
/** ... */
@example to document sample sentences
Can appear before rule definitions, root header, and language header.Copyright © 2010 Nu Echo Inc.
Grammar headersCopyright © 2010 Nu Echo Inc.
Grammar HeadersSelf-identifying header
Mandatory
Encoding is optional
Can be preceded by byte order mask (BOM)‏Ex:#ABNF 1.0;#ABNF 1.0 UTF-8;Copyright © 2010 Nu Echo Inc.
Grammar HeadersLanguage
Identifies the language of the document
Required for voice grammars
Languages codes defined by RFC 3066Ex:language en;language fr-CA;Copyright © 2010 Nu Echo Inc.
Grammar HeadersMode
Indicates the type of input
Optional header
'dtmf' or 'voice' (default)Ex:mode voice;mode dtmf;Copyright © 2010 Nu Echo Inc.
Grammar HeadersRoot
Defines the grammar's top-level rule
Optional
Root rule can be either public or privateEx:root$rootRule;Copyright © 2010 Nu Echo Inc.
Grammar HeadersTag-format
Declares content type for the semantic tags (actions)‏
Value is a URI
Recognition-engine specificEx:tag-format <semantics/1.0>;        (SISR)tag-format <Nuance>;               (Nuance)tag-format <swi-semantics/1.0>;    (Nuance)tag-format <semantics-ms/1.0>;     (Microsoft)tag-format <semantics/1.0.2006>;   (LumenVox)Copyright © 2010 Nu Echo Inc.
Grammar HeadersLexicon
Specifies a pronunciation lexicon to use (a URI)‏

An ABNF Primer

Editor's Notes

  • #9 Note that Nuance GSL grammars support mixed-mode grammars. This is not possible with SRGS grammars.
  • #18 Note that in GSL grammars, if no rule is declared public, all rules are assumed public.
  • #24 Note that some engines will accept numbers (e.g., “100”). This, however, is a bad idea to rely on this because we don’t know how it will be rendered.
  • #27 Note that square brackets also group expansions
  • #34 Note that some engines have limits on the number of repeats. For instance, Loquendo has a maximum of 30.
  • #35 Note that the form “(E | $NULL)” is preferable when computing grammar weights based on data since we can have a weight computed for both branches.
  • #38 Note that this may not be supported by all engines. Even if it is, it should be tested carefully. For instance, this does not work well with OSR 3.0 (don’t know about Nuance 9).