You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
5594 lines
234 KiB
5594 lines
234 KiB
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
<head>
|
|
<meta name="generator" content=
|
|
"HTML Tidy for Linux/x86 (vers 1st November 2003), see www.w3.org" />
|
|
<title>Speech Recognition Grammar Specification Version 1.0</title>
|
|
<style type="text/css" xml:space="preserve">
|
|
/*<![CDATA[*/
|
|
pre {
|
|
font-family: monospace;
|
|
font-size: 85%;
|
|
white-space: pre;
|
|
background-color: rgb(204,204,255);
|
|
padding: 0.5em;
|
|
margin-left: 0;
|
|
border: none;
|
|
width: 97%;
|
|
}
|
|
pre.abnf {
|
|
background-color: rgb(255,204,204);
|
|
border: solid black thin;
|
|
margin-left: 0;
|
|
}
|
|
pre.xml {
|
|
background-color: rgb(204,204,255);
|
|
border: solid black thin;
|
|
margin-left: 0;
|
|
}
|
|
pre.dtd {
|
|
background-color: rgb(204,255,204);
|
|
border: solid black thin;
|
|
margin-left: 0;
|
|
}
|
|
pre.syntax {
|
|
background-color: rgb(232,255,255);
|
|
border: solid black thin;
|
|
margin-left: 0;
|
|
font-style: italic;
|
|
}
|
|
code {
|
|
font-size: 85%;
|
|
color: green;
|
|
font-weight: bold;
|
|
}
|
|
|
|
.tocline { list-style: none; }
|
|
table.exceptions { background-color: rgb(255,255,153); }
|
|
table {
|
|
border: black;
|
|
border-width: 1px;
|
|
}
|
|
|
|
td { background-color: rgb(234,255,234) }
|
|
|
|
.issues {
|
|
font-style: italic;
|
|
color: green;
|
|
}
|
|
.remove {
|
|
text-decoration: line-through;
|
|
color: black;
|
|
}
|
|
.new { color: red; }
|
|
.hide { display: none }
|
|
/*]]>*/
|
|
</style>
|
|
<link rel="stylesheet" type="text/css" href=
|
|
"http://www.w3.org/StyleSheets/TR/W3C-REC" />
|
|
</head>
|
|
<body>
|
|
<div>
|
|
<div class="head"><a href="http://www.w3.org/" shape=
|
|
"rect"><img src="http://www.w3.org/Icons/w3c_home" alt="W3C" width=
|
|
"72" height="48" /></a>
|
|
<h1 class="notoc" id="title">Speech Recognition Grammar
|
|
Specification Version 1.0</h1>
|
|
</div>
|
|
<!-- W3C HEADER -->
|
|
<div class="head"><!-- DATE -->
|
|
<h2 class="notoc" id="pub-date">W3C Recommendation 16
|
|
March 2004</h2>
|
|
<dl>
|
|
<dt>This version:</dt>
|
|
<dd><a href=
|
|
"http://www.w3.org/TR/2004/REC-speech-grammar-20040316/">http://www.w3.org/TR/2004/REC-speech-grammar-20040316/</a></dd>
|
|
<dt>Latest version:</dt>
|
|
<dd><a href=
|
|
"http://www.w3.org/TR/speech-grammar/">http://www.w3.org/TR/speech-grammar/</a></dd>
|
|
<dt>Previous version:</dt>
|
|
<dd><a href=
|
|
"http://www.w3.org/TR/2003/PR-speech-grammar-20031218/">http://www.w3.org/TR/2003/PR-speech-grammar-20031218/</a></dd>
|
|
<dt>Editors:</dt>
|
|
<dd>Andrew Hunt, <span>ScanSoft</span></dd>
|
|
<dd>Scott McGlashan, <span>Hewlett-Packard</span></dd>
|
|
<dt>Contributors:</dt>
|
|
<dd>See <a href="#S6" shape="rect">Acknowledgements</a></dd>
|
|
</dl>
|
|
|
|
<p>Please refer to the <a href="http://www.w3.org/2004/03/speech-grammar-errata.html"><strong>errata</strong></a> for this document, which may include some normative corrections.</p>
|
|
|
|
<p>See also <a href="http://www.w3.org/2003/03/Translations/byTechnology?technology=speech-grammar"><strong>translations</strong></a>.</p>
|
|
|
|
|
|
|
|
<p class="copyright"><a href=
|
|
"http://www.w3.org/Consortium/Legal/ipr-notice#Copyright" shape=
|
|
"rect">Copyright</a> © 2004 <a href="http://www.w3.org/" shape=
|
|
"rect"><acronym title=
|
|
"World Wide Web Consortium">W3C</acronym></a><sup>®</sup>
|
|
(<a href="http://www.csail.mit.edu/" shape="rect"><acronym title=
|
|
"Massachusetts Institute of Technology">MIT</acronym></a>, <a href=
|
|
"http://www.ercim.org/" shape="rect"><acronym title=
|
|
"European Research Consortium for Informatics and Mathematics">ERCIM</acronym></a>,
|
|
<a href="http://www.keio.ac.jp/" shape="rect">Keio</a>), All Rights
|
|
Reserved. W3C <a href=
|
|
"http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer"
|
|
shape="rect">liability</a>, <a href=
|
|
"http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks"
|
|
shape="rect">trademark</a>, <a href=
|
|
"http://www.w3.org/Consortium/Legal/copyright-documents" shape=
|
|
"rect">document use</a> and <a href=
|
|
"http://www.w3.org/Consortium/Legal/copyright-software" shape=
|
|
"rect">software licensing</a> rules apply.</p>
|
|
<hr title="Separator from Header" /></div>
|
|
<h2 class="notoc" id="id1"><a id="abstract" name="abstract" shape=
|
|
"rect">Abstract</a></h2>
|
|
<p>This document defines syntax for representing grammars for use
|
|
in speech recognition so that developers can specify the words and
|
|
patterns of words to be listened for by a speech recognizer. The
|
|
syntax of the grammar format is presented in two forms, an
|
|
Augmented BNF Form and an XML Form. The specification makes the two
|
|
representations mappable to allow automatic transformations between
|
|
the two forms.</p>
|
|
|
|
<h2 class="notoc" id="id2">Status of this Document</h2>
|
|
|
|
<p><em>This section describes the status of this document at
|
|
the time of its publication. Other documents may supersede this
|
|
document. A list of current W3C publications and the latest
|
|
revision of this technical report can be found in the
|
|
<a href="http://www.w3.org/TR/">W3C technical reports index</a>
|
|
at http://www.w3.org/TR/.</em></p>
|
|
|
|
<p>This document has been reviewed by W3C Members and other
|
|
interested parties, and it has been endorsed by the Director
|
|
as a <a
|
|
href="http://www.w3.org/2004/02/Process-20040205/tr.html#RecsW3C">W3C
|
|
Recommendation</a>. W3C's role in making the Recommendation is to
|
|
draw attention to the specification and to promote its widespread
|
|
deployment. This enhances the functionaility and interoperability
|
|
of the Web.</p>
|
|
|
|
<p>This specification is part of the W3C Speech Interface Framework
|
|
and has been developed within the <a href="http://www.w3.org/Voice/">W3C Voice Browser Activity</a> (<a href="http://www.w3.org/Voice/Activity.html">activity statement</a>) by participants in
|
|
the <a href="http://www.w3.org/Voice/Group/">Voice Browser Working
|
|
Group</a> (<a href="http://cgi.w3.org/MemberAccess/AccessRequest">W3C
|
|
Members only</a>).</p>
|
|
|
|
<p>The design of SRGS 1.0 has been widely reviewed (see the
|
|
<a href="http://www.w3.org/TR/2003/PR-speech-grammar-20031218/disposition.html">
|
|
disposition of comments</a>) and satisfies the Working Group's
|
|
technical requirements. A list of implementations is included in the
|
|
<a href="http://www.w3.org/Voice/2003/srgs-ir/">SRGS 1.0
|
|
implementation report</a>, along with the associated test suite.</p>
|
|
|
|
|
|
|
|
<p>Comments are welcome on <a
|
|
href="mailto:www-voice@w3.org">www-voice@w3.org</a> (<a
|
|
href="http://lists.w3.org/Archives/Public/www-voice/">archive</a>).
|
|
See <a href="http://www.w3.org/Mail/">W3C mailing list and archive usage
|
|
guidelines</a>.</p>
|
|
|
|
<p>The W3C maintains a list of <a
|
|
href="http://www.w3.org/2001/09/voice-disclosures.html">any patent
|
|
disclosures related to this work</a>.</p>
|
|
|
|
|
|
<!-- END OF W3C HEADER -->
|
|
<div>
|
|
<h2 class="notoc" id="id-S0"><a id="S0" name="S0" shape=
|
|
"rect">Table of Contents</a></h2>
|
|
<ul class="toc">
|
|
<li class="tocline">1. <a href="#S1" shape="rect">Introduction</a>
|
|
<ul class="toc">
|
|
<li class="tocline">1.1 <a href="#S1.1" shape="rect">Grammar
|
|
Processors and User Agents</a></li>
|
|
<li class="tocline">1.2 <a href="#S1.2" shape="rect">Scope</a></li>
|
|
<li class="tocline">1.3 <a href="#S1.3" shape="rect">Grammar
|
|
Conversions</a></li>
|
|
<li class="tocline">1.4 <a href="#S1.4" shape="rect">Semantic
|
|
Interpretation</a></li>
|
|
<li class="tocline">1.5 <a href="#S1.5" shape="rect">Embedded
|
|
Grammars</a></li>
|
|
<li class="tocline">1.6 <a href="#S1.6" shape=
|
|
"rect">Terminology</a></li>
|
|
</ul>
|
|
</li>
|
|
<li class="tocline">2. <a href="#S2" shape="rect">Rule
|
|
Expansions</a>
|
|
<ul class="toc">
|
|
<li class="tocline">2.1 <a href="#S2.1" shape=
|
|
"rect">Tokens</a></li>
|
|
<li class="tocline">2.2 <a href="#S2.2" shape="rect">Rule
|
|
References</a>
|
|
<ul class="toc">
|
|
<li class="tocline">2.2.1 <a href="#S2.2.1" shape="rect">Local
|
|
References</a></li>
|
|
<li class="tocline">2.2.2 <a href="#S2.2.2" shape="rect">External
|
|
Reference by URI</a></li>
|
|
<li class="tocline">2.2.3 <a href="#S2.2.3" shape="rect">Special
|
|
Rules</a></li>
|
|
<li class="tocline">2.2.4 <a href="#S2.2.4" shape=
|
|
"rect">Referencing N-gram Documents</a></li>
|
|
</ul>
|
|
</li>
|
|
<li class="tocline">2.3 <a href="#S2.3" shape="rect">Sequences and
|
|
Encapsulation</a></li>
|
|
<li class="tocline">2.4 <a href="#S2.4" shape=
|
|
"rect">Alternatives</a>
|
|
<ul class="toc">
|
|
<li class="tocline">2.4.1 <a href="#S2.4.1" shape=
|
|
"rect">Weights</a></li>
|
|
</ul>
|
|
</li>
|
|
<li class="tocline">2.5 <a href="#S2.5" shape="rect">Repeats</a>
|
|
<ul class="toc">
|
|
<li class="tocline">2.5.1 <a href="#S2.5.1" shape="rect">Repeat
|
|
Probabilities</a></li>
|
|
</ul>
|
|
</li>
|
|
<li class="tocline">2.6 <a href="#S2.6" shape="rect">Tags</a></li>
|
|
<li class="tocline">2.7 <a href="#S2.7" shape=
|
|
"rect">Language</a></li>
|
|
<li class="tocline">2.8 <a href="#S2.8" shape=
|
|
"rect">Precedence</a></li>
|
|
</ul>
|
|
</li>
|
|
<li class="tocline">3. <a href="#S3" shape="rect">Rule
|
|
Definitions</a>
|
|
<ul class="toc">
|
|
<li class="tocline">3.1 <a href="#S3.1" shape="rect">Basic Rule
|
|
Definition</a></li>
|
|
<li class="tocline">3.2 <a href="#S3.2" shape="rect">Scoping of
|
|
Rule Definitions</a></li>
|
|
<li class="tocline">3.3 <a href="#S3.3" shape="rect">Example
|
|
Phrases</a></li>
|
|
</ul>
|
|
</li>
|
|
<li class="tocline">4. <a href="#S4" shape="rect">Grammar
|
|
Documents</a>
|
|
<ul class="toc">
|
|
<li class="tocline">4.1 <a href="#S4.1" shape="rect">Grammar Header
|
|
Declarations</a></li>
|
|
<li class="tocline">4.2 <a href="#S4.2" shape="rect">ABNF
|
|
Self-Identifying Header</a></li>
|
|
<li class="tocline">4.3 <a href="#S4.3" shape="rect">XML Form
|
|
Prolog and Root Element</a></li>
|
|
<li class="tocline">4.4 <a href="#S4.4" shape="rect">Character
|
|
Encoding</a></li>
|
|
<li class="tocline">4.5 <a href="#S4.5" shape=
|
|
"rect">Language</a></li>
|
|
<li class="tocline">4.6 <a href="#S4.6" shape="rect">Mode</a></li>
|
|
<li class="tocline">4.7 <a href="#S4.7" shape="rect">Root
|
|
Rule</a></li>
|
|
<li class="tocline">4.8 <a href="#S4.8" shape="rect">Tag
|
|
Format</a></li>
|
|
<li class="tocline">4.9 <a href="#S4.9" shape="rect">Base URI</a>
|
|
<ul class="toc">
|
|
<li class="tocline">4.9.1 <a href="#S4.9.1" shape="rect">Resolving
|
|
Relative URIs</a></li>
|
|
</ul>
|
|
</li>
|
|
<li class="tocline">4.10 <a href="#S4.10" shape=
|
|
"rect">Pronunciation Lexicon</a></li>
|
|
<li class="tocline">4.11 <a href="#S4.11" shape="rect">Meta
|
|
Data</a>
|
|
<ul class="toc">
|
|
<li class="tocline">4.11.1 <a href="#S4.11.1" shape="rect">Meta and
|
|
HTTP-Equiv</a></li>
|
|
<li class="tocline">4.11.2 <a href="#S4.11.2" shape="rect">XML
|
|
Metadata (XML Only)</a></li>
|
|
</ul>
|
|
</li>
|
|
<li class="tocline"><span>4.12</span> <a href="#S4.12" shape=
|
|
"rect"><span>Tag</span></a></li>
|
|
<li class="tocline"><span>4.13</span> <a href="#S4.13" shape=
|
|
"rect">Comments</a></li>
|
|
<li class="tocline"><span>4.14</span> <a href="#S4.14" shape=
|
|
"rect">Grammar Fetching</a></li>
|
|
<li class="tocline"><span>4.15</span> <a href="#S4.15" shape=
|
|
"rect">ABNF Keywords</a></li>
|
|
</ul>
|
|
</li>
|
|
<li class="tocline">5. <a href="#S5" shape="rect">Conformance</a>
|
|
<ul class="toc">
|
|
<li class="tocline">5.1 <a href="#S5.1" shape="rect">Conforming XML
|
|
Form Grammar Fragments</a></li>
|
|
<li class="tocline">5.2 <a href="#S5.2" shape="rect">Conforming
|
|
Stand-Alone XML Form Document</a></li>
|
|
<li class="tocline">5.3 <a href="#S5.3" shape="rect">Using XML Form
|
|
Grammars with other Namespaces</a></li>
|
|
<li class="tocline">5.4 <a href="#S5.4" shape="rect">Conforming XML
|
|
Form Grammar Processors</a></li>
|
|
<li class="tocline">5.5 <a href="#S5.5" shape="rect">Conforming
|
|
Stand-Alone ABNF Form Grammar Documents</a></li>
|
|
<li class="tocline">5.6 <a href="#S5.6" shape="rect">Conforming
|
|
ABNF Form Grammar Processors</a></li>
|
|
<li class="tocline">5.7 <a href="#S5.7" shape="rect">Conforming
|
|
ABNF/XML Form Grammar Processors</a></li>
|
|
<li class="tocline">5.8 <a href="#S5.8" shape="rect">Conforming
|
|
User Agents</a></li>
|
|
</ul>
|
|
</li>
|
|
<li class="tocline">6. <a href="#S6" shape=
|
|
"rect">Acknowledgements</a></li>
|
|
</ul>
|
|
<ul class="toc">
|
|
<li class="tocline">Appendix A. <a href="#AppA" shape=
|
|
"rect">References</a>
|
|
<ul class="toc">
|
|
<li class="tocline">A.1 <a href="#AppA.1" shape="rect">Normative
|
|
References</a></li>
|
|
<li class="tocline">A.2 <a href="#AppA.2" shape="rect">Informative
|
|
References</a></li>
|
|
</ul>
|
|
</li>
|
|
<li class="tocline">Appendix B. <a href="#AppB" shape="rect">DTD
|
|
for XML Form Grammars</a> (Informative)</li>
|
|
<li class="tocline">Appendix C. <a href="#AppC" shape="rect">XML Schema Definition
|
|
For XML Form Grammars</a> (Normative)</li>
|
|
<li class="tocline">Appendix D. <a href="#AppD" shape="rect">Formal
|
|
Syntax for Augmented BNF Form Grammars</a> (Normative)</li>
|
|
<li class="tocline">Appendix E. <a href="#AppE" shape="rect">DTMF
|
|
Grammars</a> (Normative)</li>
|
|
<li class="tocline">Appendix F. <a href="#AppF" shape="rect">XSLT
|
|
Style Sheet to Convert XML Form Grammars to the ABNF Form</a>
|
|
(Informative)</li>
|
|
<li class="tocline">Appendix G. <a href="#AppG" shape="rect">Media
|
|
Types and File Suffix</a> (Informative)</li>
|
|
<li class="tocline">Appendix H. <a href="#AppH" shape=
|
|
"rect">Logical Parse Structure</a> (Informative)
|
|
<ul class="toc">
|
|
<li class="tocline">H.1 <a href="#AppH.1" shape="rect">Terminology
|
|
and Notation</a></li>
|
|
<li class="tocline">H.2 <a href="#AppH.2" shape="rect">Parsing Rule
|
|
References</a></li>
|
|
<li class="tocline">H.3 <a href="#AppH.3" shape=
|
|
"rect">Recursion</a></li>
|
|
</ul>
|
|
</li>
|
|
<li class="tocline">Appendix I. <a href="#AppI" shape=
|
|
"rect">Features under Consideration for Future Versions</a>
|
|
(Informative)</li>
|
|
<li class="tocline">Appendix J. <a href="#AppJ" shape=
|
|
"rect">Example Grammars in ABNF Form and XML Form</a> (Informative)
|
|
<ul>
|
|
<li class="tocline">J.1 <a href="#AppJ.1" shape="rect">Simple
|
|
Examples (English)</a></li>
|
|
<li class="tocline">J.2 <a href="#AppJ.2" shape=
|
|
"rect">Cross-Reference Examples (English)</a></li>
|
|
<li class="tocline">J.3 <a href="#AppJ.3" shape="rect">Korean
|
|
Examples</a></li>
|
|
<li class="tocline">J.4 <a href="#AppJ.4" shape="rect">Chinese
|
|
Examples</a></li>
|
|
<li class="tocline">J.5 <a href="#AppJ.5" shape="rect">Swedish
|
|
Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
<p><a id="S1" name="S1" shape="rect"></a></p>
|
|
<h2 id="id-S1">1. Introduction</h2>
|
|
<p>This document defines the syntax for grammar representation. The
|
|
grammars are intended for use by speech recognizers and other
|
|
<a href="#S1.1" shape="rect">grammar processors</a> so that
|
|
developers can specify the words and patterns of words to be
|
|
listened for by a speech recognizer.</p>
|
|
<p>The syntax of the grammar format is presented in two forms, an
|
|
<em>Augmented BNF</em> (ABNF) Form and an XML Form. The
|
|
specification ensures that the two representations are <a href=
|
|
"#S1.3" shape="rect">semantically mappable</a> to allow automatic
|
|
transformations between the two forms.</p>
|
|
<ul>
|
|
<li><em>Augmented BNF syntax (ABNF):</em> this is a plain-text
|
|
(non-XML) representation which is similar to traditional BNF
|
|
grammar and to many existing BNF-like representations commonly used
|
|
in the field of speech recognition including the JSpeech Grammar
|
|
Format <a href="#ref-jsgf" shape="rect">[JSGF]</a> from which this
|
|
specification is derived. Augmented BNF should not be confused with
|
|
Extended BNF which is used in DTDs for XML and SGML.<br clear=
|
|
"none" />
|
|
</li>
|
|
<li><em>XML:</em> This syntax uses XML elements to represent the
|
|
grammar constructs and adapts designs from the PipeBeach grammar,
|
|
TalkML <a href="#ref-talkml" shape="rect">[TALKML]</a> and a
|
|
research XML variant of the JSpeech Grammar Format <a href=
|
|
"#ref-jsgf" shape="rect">[JSGF]</a>.</li>
|
|
</ul>
|
|
<p>Both the ABNF Form and XML Form have the expressive power of a
|
|
Context-Free Grammar (CFG). A <a href="#S1.1" shape="rect">grammar
|
|
processor</a> that does not support recursive grammars has the
|
|
expressive power of a Finite State Machine (FSM) or regular
|
|
expression language. For definitions of CFG, FSM, regular
|
|
expressions and other formal computational language theory see, for
|
|
example, <a href="#ref-hu79" shape="rect">[HU79]</a>. This form of
|
|
language expression is sufficient for the vast majority of speech
|
|
recognition applications.</p>
|
|
<p>This W3C standard is known as the Speech Recognition Grammar
|
|
Specification and is modelled on the JSpeech Grammar Format
|
|
specification <a href="#ref-jsgf" shape="rect">[JSGF]</a>, which is
|
|
owned by Sun Microsystems, Inc., California, U.S.A.</p>
|
|
<h3 id="id-S1.1"><a id="S1.1" name="S1.1" shape="rect">1.1 Grammar
|
|
Processors and User Agents</a></h3>
|
|
<p>A <em>grammar processor</em> is any entity that accepts as input
|
|
grammars as described in this specification.</p>
|
|
<p>A <em>user agent</em> is a grammar processor that accepts user
|
|
input and matches that input against a grammar to produce a
|
|
recognition result that represents the detected input.</p>
|
|
<p>As the specification title implies, speech recognizers are an
|
|
important class of grammar processor. Another class of grammar
|
|
processor anticipated by this specification is a <a href=
|
|
"#term-dtmf" shape="rect">Dual-Tone Multi-Frequency</a> (DTMF)
|
|
detector. The type of input accepted by a user agent is determined
|
|
by the <a href="#S4.6" shape="rect"><code>mode</code></a> or modes
|
|
of grammars it can process: e.g. speech input for <a href="#S4.6"
|
|
shape="rect">"voice"</a> mode grammars and DTMF input for <a href=
|
|
"#AppE" shape="rect">"dtmf"</a> mode grammars.</p>
|
|
<p>For simplicity, throughout this document references to a speech
|
|
recognizer apply to other types of grammar processor unless
|
|
explicitly stated otherwise.</p>
|
|
<p>A <em>speech recognizer</em> is a user agent with the following
|
|
inputs and outputs:</p>
|
|
<ul>
|
|
<li>Input: A grammar or multiple grammars as defined by this
|
|
specification. These grammars inform the recognizer of the words
|
|
and patterns of words to listen for.</li>
|
|
<li>Input: An audio stream that may contain speech content that
|
|
matches the grammar(s).</li>
|
|
<li>Output: Descriptions of <em>results</em> that indicate details
|
|
about the speech content detected by the speech recognizer. The
|
|
format and details of the content of the result are outside the
|
|
scope of this specification. For informative purposes, most
|
|
practical recognizers will include at least a transcription of any
|
|
detected words.</li>
|
|
<li>Output: Error and other performance information may be provided
|
|
to the host environment: e.g. to a voice browser that incorporates
|
|
a grammar processor. The method of interaction with the host
|
|
environment is outside the scope of this document. The
|
|
specification does, however, require that a <a href="#S5" shape=
|
|
"rect">conformant grammar processor</a> inform the environment of
|
|
errors in parsing and other processing of grammar documents.</li>
|
|
</ul>
|
|
<h3 id="id-S1.2"><a id="S1.2" name="S1.2" shape="rect">1.2
|
|
Scope</a></h3>
|
|
<p>The primary use of a speech recognizer grammar is to permit a
|
|
speech application to indicate to a recognizer what it should
|
|
listen for, specifically:</p>
|
|
<ul>
|
|
<li>Words that may be spoken,</li>
|
|
<li>Patterns in which those words may occur,</li>
|
|
<li>Spoken language of each word.</li>
|
|
</ul>
|
|
<p>Speech recognizers may also support the Stochastic Language
|
|
Models (N-Gram) Specification <a href="#ref-ngram" shape=
|
|
"rect">[NGRAM]</a>. Both specifications define ways to set up a
|
|
speech recognizer to detect spoken input but define the word and
|
|
patterns of words by different and complementary means. Some
|
|
recognizers permit cross-references between grammars in the two
|
|
formats. The <a href="#S2.2" shape="rect">rule reference</a>
|
|
element of this specification describes how to reference an N-gram
|
|
document.</p>
|
|
<p>The grammar specification <em>does not address</em> a number of
|
|
other issues that affect speech recognition performance. Most of
|
|
the following capabilities are addressed by the context in which a
|
|
grammar is referenced or invoked: for example, through VoiceXML 2.0
|
|
<a href="#ref-vxml2" shape="rect">[VXML2]</a> or through a speech
|
|
recognizer API.</p>
|
|
<ul>
|
|
<li><em>Speaker adaptation data:</em> Some speech recognizers
|
|
support the ability to dynamically adjust to the voice of a speaker
|
|
and often the ability to store adaptation data for that voice for
|
|
future use. The speaker data may also include lists of words more
|
|
often spoken by the user. The grammar format does not explicitly
|
|
address these capabilities.</li>
|
|
<li><em>Speech recognizer configuration:</em> The grammar format
|
|
does not incorporate features for setting recognizer features such
|
|
as timeouts, recognition thresholds, search sizes or N-best result
|
|
counts.</li>
|
|
<li><em>Lexicon:</em> The grammar format does not address the
|
|
loading of lexicons or the pronunciation of words referenced by the
|
|
grammar. The W3C Voice Browser Working Group is considering the
|
|
development of a standard lexicon format. If and when a format is
|
|
developed appropriate updates will be made to this grammar
|
|
specification.</li>
|
|
<li><em>Other speech processing capabilities:</em> Speech
|
|
processing technology exists for language identification, speaker
|
|
verification (also known as voice printing), speaker recognition
|
|
(also known as speaker identification) amongst many other
|
|
capabilities. Although these technologies may be associated with a
|
|
speech recognizer they are outside the scope of this
|
|
specification.</li>
|
|
</ul>
|
|
<h3 id="id-S1.3"><a id="S1.3" name="S1.3" shape="rect">1.3 Grammar
|
|
Conversions</a></h3>
|
|
<p>The ABNF Form and XML Form <span>are</span> specified to ensure
|
|
that the two representations are semantically mappable. It should
|
|
be possible to automatically convert an ABNF Form grammar to an XML
|
|
Form grammar (or the reverse) so that the semantic performance of
|
|
the grammars are identical. Equivalence of semantic performance
|
|
implies that:</p>
|
|
<ol>
|
|
<li>Both grammars accept the same language as input and reject the
|
|
same language as input</li>
|
|
<li>Both grammars parse any input string identically</li>
|
|
</ol>
|
|
<p>The XSL Transformation document in <a href="#AppF" shape=
|
|
"rect">Appendix F</a> demonstrates automatic conversion from XML to
|
|
ABNF. The reverse conversion requires an ABNF parser and a
|
|
transformational program.</p>
|
|
<p>There are inherent limits to the automatic conversion to and
|
|
From ABNF Form and XML Form.</p>
|
|
<ul>
|
|
<li>Formatting <a href="#term-whitespace" shape="rect">white
|
|
space</a> cannot be preserved so a pretty-printable grammar in one
|
|
Form cannot guarantee automatic conversion to a pretty-printable
|
|
grammar in the other Form. Note: syntactically significant white
|
|
space is preserved.</li>
|
|
<li>Some XML constructs have no equivalent in ABNF: XML Schema, DTD,
|
|
character and entity declarations and references, processing
|
|
instructions, namespaces. The XML parser in a <a href="#S5.4"
|
|
shape="rect">conforming grammar processor</a> should expand all
|
|
character and entity references as defined in XML 1.0 <a href=
|
|
"#ref-xml" shape="rect">[XML]</a> prior to conversion to ABNF;
|
|
other constructs are lost. RDF <a href="#ref-rdf-syntax" shape=
|
|
"rect">[RDF-SYNTAX]</a> represents metadata as XML within XML Form
|
|
grammar but could not be effectively utilized in ABNF Form grammars
|
|
and so is not supported.</li>
|
|
<li>Comment ordering with respect to grammar constructs may be
|
|
modified.</li>
|
|
</ul>
|
|
<h3 id="id-S1.4"><a id="S1.4" name="S1.4" shape="rect">1.4 Semantic
|
|
Interpretation</a></h3>
|
|
<p>A speech recognizer is capable of matching audio input against a
|
|
grammar to produce a <em>raw text</em> transcription (also known as
|
|
<em>literal text</em>) of the detected input. A recognizer may be
|
|
capable of, but is not required to, perform subsequent processing
|
|
of the raw text to produce a <em>semantic interpretation</em> of
|
|
the input.</p>
|
|
<p>For example, the natural language utterance <em>"I want to book
|
|
a flight from Prague to Paris"</em> could result in the following
|
|
XML data structure. To perform this additional interpretation step
|
|
requires semantic processing instructions that may be contained
|
|
within a grammar that defines the legal spoken input or in an
|
|
associated document.</p>
|
|
<pre class="xml" xml:space="preserve">
|
|
<book-flight>
|
|
<depart>Prague</depart>
|
|
<arrive>Paris</arrive>
|
|
</book-flight>
|
|
</pre>
|
|
<p>The Speech Recognition Grammar Specification provides syntactic
|
|
support for limited semantic interpretation. The <a href="#S2.6"
|
|
shape="rect"><code>tag</code></a> construct and the <a href="#S4.8"
|
|
shape="rect"><code>tag-format</code></a> <span>and <a href="#S4.12"
|
|
shape="rect"><code>tag</code></a></span> declarations provide a
|
|
placeholder for instructions to a semantic processor.</p>
|
|
<p>The <a href="http://www.w3.org/Voice/" shape="rect">W3C Voice
|
|
Browser Working Group</a> is presently developing the <em>Semantic
|
|
Interpretation for Speech Recognition</em> specification <a href=
|
|
"#ref-sem" shape="rect">[SEM]</a>. That specification defines a
|
|
language that can be embedded in tags within SRGS grammars to
|
|
perform the interpretation process. The semantic processing is
|
|
defined with respect to the <a href="#AppH" shape=
|
|
"rect"><em>logical parse structure</em></a> for grammar processing
|
|
(see <a href="#AppH" shape="rect">Appendix H</a>). Other tag
|
|
formats could be used but are outside the scope of the W3C
|
|
activities.</p>
|
|
<p>For examples of semantic interpretation in the latest working
|
|
draft see <a href="#ref-sem" shape="rect">[SEM]</a>.</p>
|
|
<p>The output of the semantic interpretation processor may be
|
|
represented using the <em>Natural Language Semantics Markup
|
|
Language</em> <a href="#ref-nlsml" shape="rect">[NLSML]</a>. This
|
|
XML representation of interpreted spoken input can be used to
|
|
transmit the result, as input to <em>VoiceXML 2.0</em> <a href=
|
|
"#ref-vxml2" shape="rect">[VXML2]</a> processing or in other
|
|
ways.</p>
|
|
<p>The semantic interpretation carried out in the speech
|
|
recognition process is typically characterized by:</p>
|
|
<ul>
|
|
<li><em>Restricted context:</em> the interpretation does not
|
|
resolve deictic or anaphoric references or other language forms
|
|
that span more than a single utterance. Example: if the utterance
|
|
<em>"I want to book a flight from Prague to Paris"</em> were
|
|
followed later by <em>"I want to continue from there to
|
|
London"</em> the reference to <em>"there"</em> could be resolved to
|
|
<em>"Paris"</em>. This requires analysis spanning more than one
|
|
utterance and is typically outside the scope of the speech
|
|
recognizer, but in scope for a dialog manager (e.g. a VoiceXML
|
|
application).</li>
|
|
<li><em>Domain-specific:</em> a speech recognition grammar is
|
|
typically restricted to a narrow domain of input (e.g. collect
|
|
flight booking data). Within this domain semantic interpretation is
|
|
an achievable task whereas semantic interpretation for an entire
|
|
language is an extraordinarily complex task.</li>
|
|
<li><em>Language-specific:</em> because each language has unique
|
|
linguistic structures the process of converting from a raw text to
|
|
a semantic result is necessarily language-specific.</li>
|
|
</ul>
|
|
<p>It is this restricted form of semantic interpretation that this
|
|
approach is intended to support. A VoiceXML application that
|
|
receives a speech result with semantic interpretation will
|
|
typically process the user input to carry out a dialog. The
|
|
application may also perform deeper semantic analysis, for example
|
|
resolving deictic or anaphoric references.</p>
|
|
<h3 id="id-S1.5"><a id="S1.5" name="S1.5" shape="rect">1.5 Embedded
|
|
Grammars</a></h3>
|
|
<p>The Speech Recognition Grammar Specification is designed to
|
|
permit ABNF Form and XML Form grammars to be embedded into other
|
|
documents. For example, VoiceXML 1.0 <a href="#ref-vxml1" shape=
|
|
"rect">[VXML1]</a> and VoiceXML 2.0 <a href="#ref-vxml2" shape=
|
|
"rect">[VXML2]</a> permit <a href=
|
|
"http://www.w3.org/TR/voicexml20/#dml3.1.1.1" shape="rect">inline
|
|
grammars</a> <a href="#ref-vxml2" shape="rect">[VXML2
|
|
§3.1.1.1]</a> in which an ABNF Form grammar or XML Form
|
|
grammar is contained within a VoiceXML document.</p>
|
|
<p>Embedding an XML Form grammar within an XML document can be
|
|
achieved with XML namespaces <a href="#ref-xmlns" shape=
|
|
"rect">[XMLNS]</a> or by incorporating the grammar <a href="#AppC"
|
|
shape="rect">XML Schema definition</a> or <a href="#AppB" shape="rect">DTD</a>
|
|
into to enclosing document's schema or DTD.</p>
|
|
<p>An ABNF Form grammar may be embedded into any XML document as
|
|
character data. ABNF grammars will often contain angle brackets
|
|
which require special handling within XML. A <a href=
|
|
"http://www.w3.org/TR/2000/REC-xml-20001006#sec-cdata-sect" shape=
|
|
"rect">CDATA</a> section <a href="#ref-xml" shape="rect">[XML
|
|
§2.7]</a> or the escape sequences of "<code>&lt;</code>"
|
|
and "<code>&gt;</code>" may be required to create well-formed
|
|
XML. Note: angle brackets ('<' and '>') are used in ABNF to
|
|
delimit any <a href="#term-uri" shape="rect">URI</a>, <a href=
|
|
"#term-media-type" shape="rect">media type</a> or <a href="#S2.5"
|
|
shape="rect">repeat operator</a>.</p>
|
|
<h3 id="id-S1.6"><a id="S1.6" name="S1.6" shape="rect">1.6
|
|
Terminology</a></h3>
|
|
<dl>
|
|
<dt><b><em><a id="term-requirements" name="term-requirements"
|
|
shape="rect">Requirements terms</a></em></b></dt>
|
|
<dd>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL
|
|
NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL"
|
|
in this document are to be interpreted as described in <a href=
|
|
"#ref-rfc2119" shape="rect">[RFC2119]</a>. However, for
|
|
readability, these words do not appear in all uppercase letters in
|
|
this specification.</dd>
|
|
<dt><br clear="none" />
|
|
<b><em><a id="term-uri" name="term-uri" shape="rect">URI: Uniform
|
|
Resource Identifier</a></em></b></dt>
|
|
<dd>A URI is a unifying syntax for the expression of names and
|
|
addresses of objects on the network as used in the World Wide Web.
|
|
A URI is defined as any legal '<code><a href=
|
|
"http://www.w3.org/TR/xmlschema-2/#anyURI" shape=
|
|
"rect">anyURI</a></code> ' primitive as defined in XML Schema Part
|
|
2: Datatypes <a href="#ref-schema2" shape="rect">[SCHEMA2
|
|
§3.2.17]</a>. The XML Schema definition follows <a href=
|
|
"#ref-rfc2396" shape="rect">[RFC2396]</a> and <a href=
|
|
"#ref-rfc2732" shape="rect">[RFC2732]</a>. The syntax
|
|
representation of a URI differs between the ABNF Form and the XML
|
|
Form. Any relative URI reference must be resolved according to the
|
|
rules given in <a href="#S4.9.1" shape="rect">Section 4.9.1</a>.
|
|
<ul>
|
|
<li><b>ABNF URI</b>: in the ABNF Form of this specification a URI
|
|
is delimited by angle brackets ('<' '>'). For example,
|
|
<code><http://www.example.com/file-path></code></li>
|
|
<li><b>XML URI</b>: in the XML Form of this specification any URI
|
|
is provided as an attribute to an element; for example the <a href=
|
|
"#S2.2" shape="rect"><code>ruleref</code></a> and <a href="#S4.10"
|
|
shape="rect"><code>lexicon</code></a> elements.</li>
|
|
</ul>
|
|
</dd>
|
|
<dt><br clear="none" />
|
|
<b><em><a id="term-media-type" name="term-media-type" shape=
|
|
"rect">Media Type</a></em></b></dt>
|
|
<dd>A <em>media type</em> (defined in <a href="#ref-rfc2045" shape=
|
|
"rect">[RFC2045]</a> and <a href="#ref-rfc2046" shape=
|
|
"rect">[RFC2046]</a>) specifies the nature of a linked resource.
|
|
Media types are case insensitive. A list of registered media types
|
|
is available for download <a href="#ref-mimetypes" shape=
|
|
"rect">[TYPES]</a>. In places where a URI can be specified a media
|
|
type may be provided to indicate the content type of <a href=
|
|
"#term-uri" shape="rect">URI</a>.
|
|
<p>[See <a href="#AppG" shape="rect">Appendix G</a> for information
|
|
on media types for the ABNF and XML Forms of the Speech Recognition
|
|
Grammar Specification.]</p>
|
|
<ul>
|
|
<li><b>ABNF URI with Media Type</b>: in the ABNF Form a media type
|
|
may be attached as a postfix to any URI. The media type is
|
|
delimited by angle brackets ('<' '>') and the URI and media
|
|
type are separated by a tilde character ('~') without intervening
|
|
<a href="#term-whitespace" shape="rect">white space</a>. For
|
|
example,<br clear="none" />
|
|
<code><http://example.com/file-path>~<media-type></code></li>
|
|
<li><b>XML URI with Media Type</b>: in the XML Form any element
|
|
that carries a URI attribute may carry a <code>type</code>
|
|
attribute.</li>
|
|
</ul>
|
|
</dd>
|
|
<dt><br clear="none" />
|
|
<b><em><a id="term-language" name="term-language" shape=
|
|
"rect">Language identifier</a></em></b></dt>
|
|
<dd>A <em>language identifier</em> labels information content as
|
|
being of a particular human language variant. Following the
|
|
<a href="http://www.w3.org/TR/2000/REC-xml-20001006#sec-lang-tag"
|
|
shape="rect">XML specification for language identification</a>
|
|
<a href="#ref-xml" shape="rect">[XML §2.12]</a> a legal
|
|
language identifier in ABNF Form grammars and XML Form grammars is
|
|
identified by an RFC 3066 <a href="#ref-rfc3066" shape=
|
|
"rect">[RFC3066]</a> code. A language code is required by RFC 3066.
|
|
A country code or other subtag identifier is optional by RFC 3066.
|
|
A grammar's <a href="#S4.5" shape="rect">language declaration</a>
|
|
declares the language of a grammar. Additionally a legal rule
|
|
expansion may be labeled by its <a href="#S2.7" shape=
|
|
"rect">language content</a>.</dd>
|
|
<dt><br clear="none" />
|
|
<b><em><a id="term-whitespace" name="term-whitespace" shape=
|
|
"rect">White space</a></em></b></dt>
|
|
<dd>White space consists of one or more space (#x20) characters,
|
|
carriage returns, line feeds, or tabs. The normative definition for
|
|
both ABNF and XML follows the <a href=
|
|
"http://www.w3.org/TR/2000/REC-xml-20001006#sec-common-syn" shape=
|
|
"rect">XML <em>white space</em> definition</a> <a href="#ref-xml"
|
|
shape="rect">[XML §2.3]</a>. ABNF processors must also follow
|
|
the <a href=
|
|
"http://www.w3.org/TR/2000/REC-xml-20001006#sec-line-ends" shape=
|
|
"rect">end-of-line handling</a> of XML 1.0 <a href="#ref-xml"
|
|
shape="rect">[XML §2.11]</a>.</dd>
|
|
<dt><br clear="none" />
|
|
<b><em><a id="term-dtmf" name="term-dtmf" shape=
|
|
"rect">DTMF</a></em></b></dt>
|
|
<dd>DTMF (Dual Tone Multiple Frequency) is an <a href=
|
|
"http://www.itu.int/" shape="rect">ITU</a> standard for telephony
|
|
signaling. ITU Recommendation Q.23 defines DTMF generation. ITU
|
|
Recommendation Q.24 <a href="#ref-q24" shape="rect">[Q24]</a>
|
|
defines DTMF reception. A grammar processor that accepts DTMF input
|
|
should implement Q.24.</dd>
|
|
</dl>
|
|
<h2 id="id-S2"><a id="S2" name="S2" shape="rect">2. Rule
|
|
Expansions</a></h2>
|
|
<ul>
|
|
<li class="tocline">2.1 <a href="#S2.1" shape=
|
|
"rect">Tokens</a></li>
|
|
<li class="tocline">2.2 <a href="#S2.2" shape="rect">Rule
|
|
References</a>
|
|
<ul>
|
|
<li class="tocline">2.2.1 <a href="#S2.2.1" shape="rect">Local
|
|
References</a></li>
|
|
<li class="tocline">2.2.2 <a href="#S2.2.2" shape="rect">External
|
|
Reference by URI</a></li>
|
|
<li class="tocline">2.2.3 <a href="#S2.2.3" shape="rect">Special
|
|
Rules</a></li>
|
|
<li class="tocline">2.2.4 <a href="#S2.2.4" shape=
|
|
"rect">Referencing N-gram Documents</a></li>
|
|
</ul>
|
|
</li>
|
|
<li class="tocline">2.3 <a href="#S2.3" shape="rect">Sequences and
|
|
Encapsulation</a></li>
|
|
<li class="tocline">2.4 <a href="#S2.4" shape=
|
|
"rect">Alternatives</a>
|
|
<ul>
|
|
<li class="tocline">2.4.1 <a href="#S2.4.1" shape=
|
|
"rect">Weights</a></li>
|
|
</ul>
|
|
</li>
|
|
<li class="tocline">2.5 <a href="#S2.5" shape="rect">Repeats</a>
|
|
<ul>
|
|
<li class="tocline">2.5.1 <a href="#S2.5.1" shape="rect">Repeat
|
|
Probabilities</a></li>
|
|
</ul>
|
|
</li>
|
|
<li class="tocline">2.6 <a href="#S2.6" shape="rect">Tags</a></li>
|
|
<li class="tocline">2.7 <a href="#S2.7" shape=
|
|
"rect">Language</a></li>
|
|
<li class="tocline">2.8 <a href="#S2.8" shape=
|
|
"rect">Precedence</a></li>
|
|
</ul>
|
|
<p>A <em>legal rule expansion</em> is any legal <a href="#S2.1"
|
|
shape="rect">token</a>, <a href="#S2.2" shape="rect">rule
|
|
reference</a>, <a href="#S2.6" shape="rect">tag</a>, or any logical
|
|
combination of legal rule expansions as <a href="#S2.3" shape=
|
|
"rect">sequence</a>, <a href="#S2.4" shape="rect">alternatives</a>,
|
|
<a href="#S2.5" shape="rect">repeated expansion</a> or <a href=
|
|
"#S2.7" shape="rect">language-attributed expansion</a>.</p>
|
|
<p>A rule expansion is formally a <em>regular expression</em> (see,
|
|
for example, <a href="#ref-hu79" shape="rect">[HU79]</a>).</p>
|
|
<p>A <a href="#S3" shape="rect"><em>rule definition</em></a>
|
|
associates a legal rule expansion with a rulename.</p>
|
|
<h3 id="id-S2.1"><a id="S2.1" name="S2.1" shape="rect">2.1
|
|
Tokens</a></h3>
|
|
<p>A <em>token</em> (a.k.a. a terminal symbol) is the part of a
|
|
grammar that defines words or other entities that may be spoken.
|
|
Any legal token is a <a href="#S2" shape="rect">legal
|
|
expansion</a>.</p>
|
|
<p>For speech recognition, a token is typically an orthographic
|
|
entity of the <a href="#S2.7" shape="rect">language</a> being
|
|
recognized. However, a token may be any string that the speech
|
|
recognizer can convert to a phonetic representation.</p>
|
|
<p><a id="token-content" name="token-content" shape="rect"></a>
|
|
<em>Token Content:</em> In both the <a href="#S2.1-xml" shape=
|
|
"rect">XML Form</a> and <a href="#S2.1-abnf" shape="rect">ABNF
|
|
Form</a> any unmarked text within a rule definition, except
|
|
<a href="#S3.3" shape="rect">example phrases</a> (XML only) or
|
|
<a href="#S2.6" shape="rect">tag content</a>, is <em>token
|
|
content</em>. The unmarked text is delimited by any syntactic
|
|
construct of the grammar form (see below for details on the ABNF
|
|
Form and XML Form). For each token content span in a grammar the
|
|
grammar processor applies the following <a href="#tokenization"
|
|
shape="rect">tokenization</a>, <a href="#ws-normalization" shape=
|
|
"rect">white space normalization</a>, <a href=
|
|
"#token-normalization" shape="rect">token normalization</a> and
|
|
<a href="#pron-lookup" shape="rect">pronunciation lookup</a>
|
|
processes. All token content in both the XML Form and ABNF Form is
|
|
treated as <a href=
|
|
"http://www.w3.org/TR/2000/REC-xml-20001006#charsets" shape=
|
|
"rect">Characters</a> in <a href="#ref-xml" shape="rect">[XML]</a>.
|
|
(informative: XML specifies Characters by reference to ISO/IEC
|
|
10646 <a href="#ref-iso10646" shape="rect">[ISO/IEC 10646]</a> and
|
|
Unicode <a href="#ref-unicode" shape="rect">[Unicode]</a>.)</p>
|
|
<a id="tokenization" name="tokenization" shape="rect"></a>
|
|
<p><em>Tokenization behavior</em>: Text spans containing token
|
|
sequences are delimited as follows:</p>
|
|
<ul>
|
|
<li>XML Form only: a <token> element may contain character
|
|
data only. The character data is treated as a single unnormalized
|
|
token. The character data must not contain any double quote
|
|
characters.</li>
|
|
<li>Any token in ABNF Form or XML Form (except within <token>
|
|
element in XML Form) may be delimited by double quotes. The text
|
|
contained within the double quotes is an unnormalized token. The
|
|
text must not contain any double quote characters. A token
|
|
delimited by double quotes may contain white space.</li>
|
|
<li>Any token content not delimited by a <token> element or
|
|
double quotes is treated as a sequence of white-space-delimited
|
|
tokens. Each token contained in the token content is delimited at
|
|
the start and at the end by any white space character or any
|
|
syntactic construct that delimits a token content span. The
|
|
syntactic constructs that delimit token content are different for
|
|
the ABNF Form and XML Form. These tokens cannot contain white space
|
|
characters.</li>
|
|
</ul>
|
|
<table border="1" cellpadding="3" summary="Token Syntax Examples">
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><b>Token type</b></td>
|
|
<td colspan="1" rowspan="1"><b>Form</b></td>
|
|
<td colspan="1" rowspan="1"><b>Example</b></td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1">Single unquoted token</td>
|
|
<td colspan="1" rowspan="1">ABNF & XML</td>
|
|
<td colspan="1" rowspan="1">hello</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1">Single unquoted token:
|
|
non-alphabetic</td>
|
|
<td colspan="1" rowspan="1">ABNF & XML</td>
|
|
<td colspan="1" rowspan="1">2</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1">Single quoted token: including white
|
|
space</td>
|
|
<td colspan="1" rowspan="1">ABNF & XML</td>
|
|
<td colspan="1" rowspan="1">"San Francisco"</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1">Single quoted token: no white
|
|
space</td>
|
|
<td colspan="1" rowspan="1">ABNF & XML</td>
|
|
<td colspan="1" rowspan="1">"hello"</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1">Two tokens delimited by white
|
|
space</td>
|
|
<td colspan="1" rowspan="1">ABNF & XML</td>
|
|
<td colspan="1" rowspan="1">bon voyage</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1">Four tokens delimited by white
|
|
space</td>
|
|
<td colspan="1" rowspan="1">ABNF & XML</td>
|
|
<td colspan="1" rowspan="1">this is a test</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1">Single XML token in <token></td>
|
|
<td colspan="1" rowspan="1">XML Only</td>
|
|
<td colspan="1" rowspan="1"><token>San
|
|
Francisco</token></td>
|
|
</tr>
|
|
</table>
|
|
<a id="ws-normalization" name="ws-normalization" shape="rect"></a>
|
|
<p><em>White Space Normalization:</em> White space must be
|
|
normalized when contained in any token delimited by a <token>
|
|
elements or by double quotes. Leading and trailing white space
|
|
characters are stripped. Any token-internal white space character
|
|
or sequence is collapsed to a single space character (#x20). For
|
|
example, the following are all normalized to the same string, "San
|
|
Francisco".</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
"San Francisco"
|
|
" San Francisco "
|
|
"San
|
|
Francisco"
|
|
" San Francisco "
|
|
</pre>
|
|
<p>Because the presence of white space within a token is
|
|
significant the following are distinct tokens.</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
"San Francisco"
|
|
"SanFrancisco"
|
|
"San_Francisco"
|
|
</pre>
|
|
<a id="token-normalization" name="token-normalization" shape=
|
|
"rect"></a>
|
|
<p><em>Token Normalization:</em> Other normalization processes are
|
|
applied to the white space normalized token according to the
|
|
language and the capabilities of the speech recognizer.</p>
|
|
<p>Grammar processors may assume <a href=
|
|
"http://www.w3.org/TR/2003/WD-charmod-20030822/#sec-Normalization" shape=
|
|
"rect">Early Uniform Normalization</a> as defined in the Character
|
|
Model for the World Wide Web 1.0 <a href="#ref-charmod" shape=
|
|
"rect">[CHARMOD §4]</a>.</p>
|
|
<a id="pron-lookup" name="pron-lookup" shape="rect"></a>
|
|
<p><em>Pronunciation Lookup:</em> To match spoken (audio) input to
|
|
a grammar a speech recognition must be capable of modelling the
|
|
audio patterns of any token in a grammar. Speech recognizers employ
|
|
a diverse set of techniques for performing this key recognition
|
|
process. The following is an informative description of techniques
|
|
that a speech recognizer may apply based on conventional large
|
|
vocabulary speech recognition technology.</p>
|
|
<p>A large vocabulary speech recognizer converts each normalized
|
|
token to a phoneme sequence or a set of possible phoneme sequences.
|
|
Conversion of an orthographic form (token) to the spoken form
|
|
(phonemes) is a highly language-specific process. In many cases the
|
|
conversion is even specific to a national variant, regional dialect
|
|
or other variant of the language. For example, for some tokens
|
|
Parisian French, Quebec French and Swiss French will each convert
|
|
to different pronunciations.</p>
|
|
<p>The text-to-phoneme conversion in a large vocabulary speech
|
|
recognizer may involve some or all of the following
|
|
sub-processes.</p>
|
|
<ul>
|
|
<li><em>Pronunciation lexicon lookup:</em> One of possibly many
|
|
lexicons available to a recognizer can provide the phoneme sequence
|
|
for a token. Both the ABNF Form and XML Form permit a grammar to
|
|
specify one or more <a href="#S4.10" shape="rect">lexicon</a>
|
|
documents. Recognizers typically provide a built-in lexicon for
|
|
each supported language though the coverage will vary between
|
|
recognizers. The algorithm by which the lookup resolves a token to
|
|
a pronunciation is defined by the lexicon format and/or the speech
|
|
recognizer and may be language-specific. Case-insensitive string
|
|
matching is recommended.</li>
|
|
<li><em>Morphological analysis:</em> a recognizer may be capable of
|
|
determining the transformation from a base token and phoneme string
|
|
to a morphological variant and its pronunciation. For example given
|
|
the pronunciation for "Hyundai" a rule could infer the
|
|
pronunciation for the pluralized form "Hyundai's".</li>
|
|
<li><em>Automatic text-to-phoneme conversion:</em> for many, but
|
|
not all, languages and scripts there are rules that automatically
|
|
convert a token into a phoneme sequence. For example, in English
|
|
most but not all words ending with the letter sequence "ise" end
|
|
with the phoneme sequence "ai z". A speech recognizer may use
|
|
automated conversion to infer pronunciations for tokens that cannot
|
|
be looked up in a lexicon.</li>
|
|
</ul>
|
|
<p>Any language is likely to have other specialized processes for
|
|
determining a pronunciation for a token. For example, for Japanese
|
|
special techniques are required for Kanji and each Kana form.</p>
|
|
<p>For any language and recognizer there may be variation in
|
|
coverage and completeness of the language's tokens.</p>
|
|
<p>When a grammar processor handles a grammar containing a token
|
|
that it cannot convert to phonemic form or otherwise use in the
|
|
speech recognition processing of audio it should inform the hosting
|
|
environment.</p>
|
|
<a id="token-limitations" name="token-limitations" shape=
|
|
"rect"></a>
|
|
<p><em>Limitations of token handling:</em> the following is
|
|
informative guidance to grammar developers.</p>
|
|
<p>The Pronunciation Lexicon activity <a href="#ref-lex" shape=
|
|
"rect">[LEX]</a> of the W3C Voice Browser Working Group will
|
|
provide guidance on the token-handling processes outlined
|
|
above.</p>
|
|
<p>Token handling will vary between recognizers and will vary
|
|
between languages.</p>
|
|
<p>Grammar authors can improve document portability by avoiding
|
|
characters and forms in tokens that do not have obvious
|
|
pronunciations in the language. For English, the following are ways
|
|
to handle some orthographic forms:</p>
|
|
<ul>
|
|
<li>Acronyms should be avoided. Alphabetic characters should be
|
|
widely available. For example, replace "USA" by "u s a"; replace
|
|
"W3C" by "w three c"; replace "IEEE" by "i triple e".</li>
|
|
<li>Abbreviations should be replaced by the unabbreviated form. For
|
|
example, replace "Dr." by "drive" or "doctor".</li>
|
|
<li>Most punctuation should be expanded to a spelled form. For
|
|
example replace "&" by "ampersand" or "and"; replace "+" by
|
|
"plus"; replace "<" by "less than" or "open angle bracket".</li>
|
|
<li>A grammar processor should support digits (e.g. "0" though "9"
|
|
for European scripts). Other natural numbers should be replaced by
|
|
spelled forms. For example, for US English replace "10" by "ten"
|
|
and "1000" by "thousand".</li>
|
|
<li>Grammar authors should consider the possibility that a grammar
|
|
will be used to interpret input in a non-speech recognition device.
|
|
For example, grammars can be used to process text strings from
|
|
keyboard input, text telephone services, pen input and other text
|
|
modalities. To facilitate text input a grammar should contain
|
|
standard orthographic tokens of the language. That is, to
|
|
facilitate non-speech recognition input the grammar should contain
|
|
standard spellings of natural language words to the greatest extent
|
|
possible.</li>
|
|
</ul>
|
|
|
|
<h4 id="id-S2.1-abnf"><a id="S2.1-abnf" name="S2.1-abnf" shape=
|
|
"rect">ABNF Form</a></h4>
|
|
<p>Any plain text within a rule definition is <a href=
|
|
"#token-content" shape="rect">token content</a>. The <a href=
|
|
"#AppD" shape="rect">ABNF Syntax (Appendix D)</a> normatively
|
|
defines the token parsing behavior.</p>
|
|
<p>A <a href="#S2.7-abnf" shape="rect">language attachment</a> may
|
|
be provided for any token. When attached to a token the language
|
|
modifies the handling of that token only.</p>
|
|
<p><em>Informative</em></p>
|
|
<p>The rule expansion of a <a href="#S3.1" shape="rect">rule
|
|
definition</a> is delimited at the start and end by equals sign
|
|
('=') and semicolon (';') respectively. Any leading plain text of
|
|
the rule expansion is delimited by ('=') and similarly any final
|
|
plain text is closed by semicolon.</p>
|
|
<p>Within a rule expansion the following symbols have syntactic
|
|
function and delimit plain text.</p>
|
|
<ul>
|
|
<li>Dollar sign ('$') and angle brackets ('<' and '>') when
|
|
needed mark <a href="#S2.2" shape="rect">rule references</a></li>
|
|
<li>Parentheses ('(' and ')') may enclose any <a href="#S2.3"
|
|
shape="rect">rule expansion</a></li>
|
|
<li>Vertical bar ('|') delimits <a href="#S2.4" shape=
|
|
"rect">alternatives</a></li>
|
|
<li>Forward slashes ('/' and '/') delimit any <a href="#S2.4.1"
|
|
shape="rect">weights</a> on alternatives</li>
|
|
<li>Angle brackets ('<' and '>') delimit any <a href="#S2.5"
|
|
shape="rect">repeat operator</a></li>
|
|
<li>Square brackets ('[' and ']') delimit any <a href="#S2.5"
|
|
shape="rect">optional expansion</a></li>
|
|
<li>Curly brackets ('{' and '}') delimit any <a href="#S2.6" shape=
|
|
"rect">tag</a></li>
|
|
<li>Exclamation point ('!') prefixes any <a href="#S2.7" shape=
|
|
"rect">language identifier</a></li>
|
|
</ul>
|
|
<p>Within plain text regions delimited by these characters the
|
|
<a href="#tokenization" shape="rect">tokenization</a>, <a href=
|
|
"#ws-normalization" shape="rect">white space normalization</a>,
|
|
<a href="#token-normalization" shape="rect">token normalization</a>
|
|
and <a href="#pron-lookup" shape="rect">pronunciation lookup</a>
|
|
processes described above apply.</p>
|
|
<h4 id="id-S2.1-xml"><a id="S2.1-xml" name="S2.1-xml" shape=
|
|
"rect">XML Form</a></h4>
|
|
<p>Any <code>token</code> element explicitly delimits a <a href=
|
|
"#S2.1" shape="rect">single token</a> as described above. The
|
|
<code>token</code> element may include an optional <a href=
|
|
"#S2.7-xml" shape="rect"><code>xml:lang</code></a> attribute to
|
|
indicate the <a href="#S2.7" shape="rect">language</a> of the
|
|
contained token.</p>
|
|
<p>Any other character data within a <a href="#S3.1" shape=
|
|
"rect">rule</a> element (rule definition) or <a href="#S2.3" shape=
|
|
"rect">item</a> element is <a href="#token-content" shape=
|
|
"rect">token content</a>. Note that character data within <a href=
|
|
"#S2.6" shape="rect">tag</a> or <a href="#S3.3" shape=
|
|
"rect">example</a> is not token text.</p>
|
|
|
|
<h3 id="id-S2.2"><a id="S2.2" name="S2.2" shape="rect">2.2 Rule
|
|
Reference</a></h3>
|
|
<p>Any legal rule reference is a <a href="#S2" shape=
|
|
"rect"><em>legal rule expansion</em></a> .</p>
|
|
<p><em>Rulenames</em>: Every <a href="#S3.1" shape="rect">rule
|
|
definition</a> has a local name that must be unique within the
|
|
scope of the grammar in which it is defined. A rulename must match
|
|
the <a href=
|
|
"http://www.w3.org/TR/2000/REC-xml-20001006#sec-common-syn" shape=
|
|
"rect">"Name" Production</a> of XML 1.0 <a href="#ref-xml" shape=
|
|
"rect">[XML §2.3]</a> and be a legal XML ID. <a href="#S3.1"
|
|
shape="rect">Section 3.1</a> documents the rule definition
|
|
mechanism and the legal naming of rules.</p>
|
|
<p>This table summarizes the various forms of rule reference that
|
|
are possible within and across grammar documents.</p>
|
|
<p>Note: an XML Form grammar document must provide one and only one
|
|
of the <code>uri</code> or <code>special</code> attributes on a
|
|
<code>ruleref</code> element. There is no equivalent constraint in
|
|
ABNF since the syntactic forms are distinct.</p>
|
|
<table cellpadding="3" border="1" summary="Rule Reference Syntax">
|
|
<tbody>
|
|
<tr>
|
|
<td rowspan="1" colspan="1"><b>Reference type</b></td>
|
|
<td rowspan="1" colspan="1"><b>ABNF Form</b></td>
|
|
<td rowspan="1" colspan="1"><b>XML Form</b></td>
|
|
</tr>
|
|
<tr>
|
|
<td rowspan="1" colspan="1"><a href="#S2.2.1">2.2.1</a>:
|
|
<span>Explicit</span> local rule reference</td>
|
|
<td rowspan="1" colspan="1"><code>$rulename</code></td>
|
|
<td rowspan="1" colspan="1"><code><ruleref
|
|
uri="#rulename"/></code></td>
|
|
</tr>
|
|
<tr>
|
|
<td rowspan="1" colspan="1"><a href="#S2.2.2">2.2.2</a>:
|
|
<span>Explicit</span> reference to a named rule of a
|
|
grammar identified by a <a href="#term-uri">URI</a></td>
|
|
<td rowspan="1" colspan="1">
|
|
<code>$<grammarURI#rulename></code></td>
|
|
<td rowspan="1" colspan="1"><code><ruleref
|
|
uri="grammarURI#rulename"/></code></td>
|
|
</tr>
|
|
<tr>
|
|
<td rowspan="1" colspan="1"><a href="#S2.2.2"
|
|
shape="rect">2.2.2</a>: <span>Implicit</span> reference to the
|
|
root rule of a grammar identified by a
|
|
<a href="#term-uri">URI</a></td>
|
|
<td rowspan="1" colspan="1"><code>$<grammarURI></code></td>
|
|
<td rowspan="1" colspan="1"><code><ruleref
|
|
uri="grammarURI"/></code></td>
|
|
</tr>
|
|
<tr>
|
|
<td rowspan="1" colspan="1"><a href="#S2.2.2">2.2.2</a>:
|
|
<span>Explicit</span> reference to a named rule of a grammar
|
|
identified by a <a href="#term-uri">URI</a> with a <a href=
|
|
"#term-media-type">media type</a></td>
|
|
<td rowspan="1" colspan="1">
|
|
<code>$<grammarURI#rulename>~<media-type></code></td>
|
|
<td rowspan="1" colspan="1"><code><ruleref
|
|
uri="grammarURI#rulename" type="media-type"/></code></td>
|
|
</tr>
|
|
<tr>
|
|
<td rowspan="1" colspan="1"><a href="#S2.2.2">2.2.2</a>:
|
|
<span>Implicit</span> reference to the root rule of a grammar
|
|
identified by a <a href="#term-uri">URI</a> with a <a href=
|
|
"#term-media-type">media type</a></td>
|
|
<td rowspan="1" colspan="1">
|
|
<code>$<grammarURI>~<media-type></code></td>
|
|
<td rowspan="1" colspan="1"><code><ruleref uri="grammarURI"
|
|
type="media-type"/></code></td>
|
|
</tr>
|
|
<tr>
|
|
<td rowspan="1" colspan="1"><a href="#S2.2.3">2.2.3</a>:
|
|
Special rule definitions</td>
|
|
<td rowspan="1" colspan="1"><code>$NULL<br clear="none" />
|
|
$VOID<br clear="none" />
|
|
$GARBAGE</code></td>
|
|
<td rowspan="1" colspan="1"><code><ruleref
|
|
special="NULL"/><br clear="none" />
|
|
<ruleref special="VOID"/><br clear="none" />
|
|
<ruleref special="GARBAGE"/></code></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<h4 id="id-S2.1.1"><a id="S2.2.1" name="S2.2.1" shape="rect">2.2.1
|
|
Local References</a></h4>
|
|
<p>When referencing rules defined locally (defined in the same
|
|
grammar as contains the reference), always use a simple rulename
|
|
reference which consists of the local rulename only. The ABNF Form
|
|
and XML Form have a different syntax for representing a simple
|
|
rulename reference.</p>
|
|
<blockquote>
|
|
<h4 id="id-S2.1.1-abnf">ABNF Form</h4>
|
|
<p>The simple rulename reference is prefixed by a "$"
|
|
character.</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
$city
|
|
$digit
|
|
</pre>
|
|
<h4 id="id-S2.1.1-xml">XML Form</h4>
|
|
<p>The <code>ruleref</code> element is an empty element with a
|
|
<code>uri</code> attribute that specifies the rule reference as a
|
|
<em>same-document reference <a href="#term-uri" shape=
|
|
"rect">URI</a></em> <a href="#ref-rfc2396" shape=
|
|
"rect">[RFC2396]</a>: that is, the attribute consists only of the
|
|
number sign ('#') and the fragment identifier that indicates the
|
|
locally referenced rulename.</p>
|
|
<pre class="xml" xml:space="preserve">
|
|
<ruleref uri="#city"/>
|
|
<ruleref uri="#digit"/>
|
|
</pre></blockquote>
|
|
<h4 id="id-S2.2.2"><a id="S2.2.2" name="S2.2.2" shape="rect">2.2.2
|
|
External Reference by URI</a></h4>
|
|
<p>References to rules defined in other grammars are legal under
|
|
the conditions defined in <a href="#S3" shape="rect">Section 3</a>.
|
|
The external reference must identify the external grammar by
|
|
<a href="#term-uri" shape="rect">URI</a> and may identify a
|
|
specific rule within that grammar. If the fragment identifier that
|
|
would indicate a rulename is omitted, then the reference
|
|
<span>implicitly</span> targets the <a href="#S4.7" shape=
|
|
"rect"><code>root</code></a> rule of the external grammar.</p>
|
|
<p>Any externally-referenced rule may be <em>activated</em> for
|
|
recognition. That is it may define the top-level syntax of spoken
|
|
input. For instance, VoiceXML <a href="#ref-vxml2" shape=
|
|
"rect">[VXML2]</a> grammar activation may explicitly reference one
|
|
or more public rules (see <a href="#S3.2" shape="rect">Section
|
|
3.2</a>) and/or implicitly reference the root rule (see <a href=
|
|
"#S4.7" shape="rect">Section 4.7</a>).</p>
|
|
<p>A URI reference is illegal if the referring document and
|
|
referenced document have different modes. For instance, it is
|
|
illegal to reference a "dtmf" grammar from a "voice" grammar. (See
|
|
<a href="#S4.6" shape="rect">Section 4.6</a> for additional detail
|
|
on modes).</p>
|
|
<p><span>A resource indicated by an <a href="#term-uri" shape=
|
|
"rect">URI</a> reference may be available in one or more <a href=
|
|
"#term-media-type" shape="rect">media types</a>. The grammar author
|
|
may specify the preferred media-type via the <code>type</code>
|
|
attribute (XML form) or in angle braces following the URI (ABNF
|
|
form).</span>When the content represented by a URI is available in
|
|
many data formats, a grammar processor may use the <span>preferred
|
|
media-</span>type to influence which of the multiple formats is
|
|
used. For instance, on a server implementing HTTP content
|
|
negotiation, the processor may use the <span>preferred
|
|
media-</span>type to order the preferences in the negotiation.</p>
|
|
<p>The resource representation delivered by dereferencing the URI
|
|
reference may be considered in terms of two types. The
|
|
<i>declared media-type</i> is the asserted value for the resource
|
|
and the <i>actual media-type</i> is the true format of its content.
|
|
The actual media-type should be the same as the declared
|
|
media-type, but this is not always the case (e.g. a misconfigured
|
|
HTTP server might return <code>text/plain</code> for an
|
|
<code>application/srgs+xml</code> document). A specific URI scheme
|
|
may require that the resource owner always, sometimes, or never
|
|
return a media-type. The declared media-type is the value returned
|
|
by the resource owner or, if none is returned, the preferred media
|
|
type given in the grammar. There may be no declared media-type if
|
|
the resource owner does not return a value and no preferred type is
|
|
specified. Whenever specified, the declared media-type is
|
|
authoritative.</p>
|
|
<p>Three special cases may arise. The declared media-type may not
|
|
be supported by the processor; this is an error. The declared
|
|
media-type may be supported but the actual media-type may not
|
|
match; this is also an error. Finally, there may be no declared
|
|
media-type; the behavior depends on the specific URI scheme and the
|
|
capabilities of the grammar processor. For instance, HTTP 1.1
|
|
allows document introspection (see <a href="#ref-rfc2616" shape=
|
|
"rect">RFC 2616</a>, section 7.2.1), the data scheme falls back to
|
|
a default media type, and local file access defines no guidelines.
|
|
The following table provides some informative examples:</p>
|
|
<table width="100%" border="1" cellpadding="3" summary=
|
|
"Media type examples">
|
|
<tr>
|
|
<td width="20%" rowspan="1" colspan="1"></td>
|
|
<td colspan="2" rowspan="1">
|
|
<div align="center"><b>HTTP 1.1 request</b></div>
|
|
</td>
|
|
<td colspan="2" rowspan="1">
|
|
<div align="center"><b>Local file access</b></div>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td width="20%" rowspan="1" colspan="1">Media-type returned by the
|
|
resource owner</td>
|
|
<td width="20%" rowspan="1" colspan="1">text/plain</td>
|
|
<td width="20%" rowspan="1" colspan="1">application/srgs+xml</td>
|
|
<td width="20%" rowspan="1" colspan="1"><none></td>
|
|
<td rowspan="1" colspan="1"><none></td>
|
|
</tr>
|
|
<tr>
|
|
<td width="20%" rowspan="1" colspan="1">Preferred media-type
|
|
appearing in the grammar</td>
|
|
<td colspan="2" rowspan="1">Not applicable; the returned type takes
|
|
precedence</td>
|
|
<td width="20%" rowspan="1" colspan="1">application/srgs+xml</td>
|
|
<td rowspan="1" colspan="1"><none></td>
|
|
</tr>
|
|
<tr>
|
|
<td width="20%" rowspan="1" colspan="1">Declared media-type</td>
|
|
<td width="20%" rowspan="1" colspan="1">text/plain</td>
|
|
<td width="20%" rowspan="1" colspan="1">application/srgs+xml</td>
|
|
<td width="20%" rowspan="1" colspan="1">application/srgs+xml</td>
|
|
<td rowspan="1" colspan="1"><none></td>
|
|
</tr>
|
|
<tr>
|
|
<td width="20%" rowspan="1" colspan="1">Behavior if the actual
|
|
media-type is application/srgs+xml</td>
|
|
<td width="20%" rowspan="1" colspan="1">Error; the declared and
|
|
actual types do not match</td>
|
|
<td colspan="2" rowspan="1">The declared and actual types match;
|
|
success if application/srgs+xml is supported by the grammar
|
|
processor; otherwise an error</td>
|
|
<td rowspan="1" colspan="1">Scheme specific; the grammar processor
|
|
might introspect the document to determine the type.</td>
|
|
</tr>
|
|
</table>
|
|
<p>See <a href="#AppG" shape="rect">Appendix G</a> for a summary of
|
|
the status for media types for ABNF Form and XML Form grammars.</p>
|
|
<blockquote>
|
|
<h4 id="id-S2.2.2-abnf">ABNF Form</h4>
|
|
<p>In ABNF an external reference by URI is represented by a dollar
|
|
sign ('$') followed immediately by either an <a href="#term-uri"
|
|
shape="rect">ABNF URI</a> or <a href="#term-media-type" shape=
|
|
"rect">ABNF URI with media type</a>. There must be no <a href=
|
|
"#term-whitespace" shape="rect">white space</a> between the dollar
|
|
sign and the URI.</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
// References to specific rules of an external grammar
|
|
$<http://grammar.example.com/world-cities.gram#canada>
|
|
$<http://grammar.example.com/numbers.gram#digit>
|
|
|
|
// <span>Implicit</span> reference to the root rule of an external grammar
|
|
$<../date.gram>
|
|
|
|
// References with associated media types
|
|
$<http://grammar.example.com/world-cities.gram#canada>~<application/srgs>
|
|
$<../date.gram>~<application/srgs>
|
|
</pre>
|
|
<p>Note: the media type of <code>"application/srgs"</code> has been
|
|
requested for ABNF Form grammars. See <a href="#AppG" shape=
|
|
"rect">Appendix G</a> for details.</p>
|
|
<h4 id="id-S2.2.2-xml">XML Form</h4>
|
|
<p>An XML rule reference is represented by a <code>ruleref</code>
|
|
element with a <code>uri</code> attribute that defines the <a href=
|
|
"#term-uri" shape="rect">URI</a> of the referenced grammar and rule
|
|
within it. If a fragment identifier is appended then the identifier
|
|
indicates a specific rulename being referenced. If the fragment
|
|
identifier is omitted then the reference is
|
|
<span>(implicitly)</span> to the root rule of the referenced
|
|
grammar.</p>
|
|
<p>The optional <code>type</code> attribute specifies the <a href=
|
|
"#term-media-type" shape="rect">media type</a> of the grammar
|
|
containing the reference.</p>
|
|
<pre class="xml" xml:space="preserve">
|
|
<!-- References to specific rules of an external grammar -->
|
|
<ruleref uri="http://grammar.example.com/world-cities.<span>grxml</span>#canada"/>
|
|
<ruleref uri="http://grammar.example.com/numbers.<span>grxml</span>#digit"/>
|
|
|
|
<!-- <span>Implicit</span> reference to the root rule of an external grammar -->
|
|
<ruleref uri="../date.<span>grxml</span>"/>
|
|
|
|
<!-- References with associated media types -->
|
|
<ruleref uri="http://grammar.example.com/world-cities.<span>grxml</span>#canada"
|
|
type="application/srgs+xml"/>
|
|
<ruleref uri="../date.<span>grxml</span>" type="application/srgs+xml"/>
|
|
</pre>
|
|
<p>Note: the media type <code>"application/srgs+xml"</code> has
|
|
been requested for XML Form grammars. See <a href="#AppG" shape=
|
|
"rect">Appendix G</a> for details on media types for grammars.</p>
|
|
</blockquote>
|
|
<h4 id="id-S2.2.3"><a id="S2.2.3" name="S2.2.3" shape="rect">2.2.3
|
|
Special Rules</a></h4>
|
|
<p>Several rulenames are defined to have specific interpretation
|
|
and processing by a speech recognizer. A grammar must not redefine
|
|
these rulenames.</p>
|
|
<p>In the ABNF Form a special rule reference is syntactically
|
|
identical to a <a href="#S2.2.1" shape="rect">local rule
|
|
reference</a>. However, the names of the special rules are
|
|
<em>reserved</em> to prevent a <a href="#S3.1" shape="rect">rule
|
|
definition</a> with the same name.</p>
|
|
<p>In the XML Form a special rulename is represented with the
|
|
<code>special</code> attribute on a <code>ruleref</code> element.
|
|
It is illegal to provide both the <code>special</code> and the
|
|
<code>uri</code> attributes.</p>
|
|
<dl>
|
|
<dt><b>NULL</b></dt>
|
|
<dd>Defines a rule that is automatically matched: that is, matched
|
|
without the user speaking any word.
|
|
<p>ABNF Form: <code>$NULL</code><br clear="none" />
|
|
XML Form: <code><ruleref special="NULL"/></code></p>
|
|
</dd>
|
|
<dt><b>VOID</b></dt>
|
|
<dd>Defines a rule that can never be spoken. Inserting VOID into a
|
|
sequence automatically makes that sequence unspeakable.
|
|
<p>ABNF Form: <code>$VOID</code><br clear="none" />
|
|
XML Form: <code><ruleref special="VOID"/></code></p>
|
|
</dd>
|
|
<dt><b>GARBAGE</b></dt>
|
|
<dd>Defines a rule that may match any speech up until the next rule
|
|
match, the next token or until the end of spoken input. A grammar
|
|
processor must accept grammars that contain special references to
|
|
GARBAGE. The behavior GARBAGE rule is implementation-specific. A
|
|
user agent should be capable of matching arbitrary spoken input up
|
|
to the next token but may treat GARBAGE as equivalent to NULL
|
|
(match no spoken input).
|
|
<p>ABNF Form: <code>$GARBAGE</code><br clear="none" />
|
|
XML Form: <code><ruleref special="GARBAGE"/></code></p>
|
|
<b>Informative example:</b> given suitable definitions of US cities
|
|
and states, a speech recognizer may implement the following ABNF
|
|
and XML rule definitions to match <em>"Philadelphia in the great
|
|
state of Pennsylvania"</em> as well as simply <em>"Philadelphia
|
|
Pennsylvania"</em>.
|
|
<pre class="abnf" xml:space="preserve">
|
|
$location = $city $GARBAGE $state;
|
|
</pre>
|
|
<pre class="xml" xml:space="preserve">
|
|
<rule id="location">
|
|
<ruleref uri="#city"/>
|
|
<ruleref special="GARBAGE"/>
|
|
<ruleref uri="#state"/>
|
|
</rule>
|
|
</pre></dd>
|
|
</dl>
|
|
<h4 id="id-S2.2.4"><a id="S2.2.4" name="S2.2.4" shape="rect">2.2.4
|
|
Referencing N-gram Documents (Informative)</a></h4>
|
|
<p>The W3C Voice Browser Working Group has released a Working Draft
|
|
for the Stochastic Language Models (N-Gram) Specification <a href=
|
|
"#ref-ngram" shape="rect">[NGRAM]</a>. These two specifications
|
|
represent different and complementary ways of informing a speech
|
|
recognizer of which words and patterns of words to listen for.</p>
|
|
<p>A speech recognizer may choose to support the Speech Recognition
|
|
N-Gram Grammar Specification in addition to the speech recognition
|
|
grammar defined in this document.</p>
|
|
<p>If a speech recognizer supports both grammar representations it
|
|
may optionally support references between the two formats. Grammars
|
|
defined in the ABNF Form or XML Form may reference start symbols of
|
|
N-Gram documents and vice versa.</p>
|
|
<p>The syntax for referencing an N-Gram is the same as referencing
|
|
externally defined ABNF Form or XML Form grammar documents. A media
|
|
type is recommended on a reference to an N-gram document. The
|
|
Working Group has not yet applied for a type on N-gram documents so
|
|
no example is given. The fragment identifier (a rulename when
|
|
referencing ABNF Form and XML Form grammars) identifies a <em>start
|
|
symbol</em> as defined by the N-Gram specification. If the start
|
|
symbol is absent the N-Gram, as a whole, is referenced as defined
|
|
in the N-Gram specification.</p>
|
|
<blockquote>
|
|
<h4 id="id-S2.2.4-abnf">ABNF Form</h4>
|
|
<p><a href="#S2.2.2" shape="rect">URI references</a> to N-Gram
|
|
documents follow the same syntax as references to other ABNF or XML
|
|
Form grammar documents. The following are examples of references to
|
|
an N-Gram document via an <a href="#S2.2.2" shape="rect">explicit
|
|
rule reference</a> and a<span>n implicit</span> reference to the
|
|
<a href="#S2.2.2" shape="rect">root rule</a>.</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
$<http://grammar.example.com/ngram.xml#StartSymbol>
|
|
$<http://grammar.example.com/ngram.xml>
|
|
</pre>
|
|
<h4 id="id-S2.2.4-xml">XML Form</h4>
|
|
<p><a href="#S2.2.2" shape="rect">URI references</a> to N-Gram
|
|
documents follow the same syntax as reference to other ABNF Form
|
|
and XML Form grammar documents. The following are examples of
|
|
references to an N-Gram document via an <a href="#S2.2.2" shape=
|
|
"rect">explicit rule reference</a> and a<span>n implicit</span>
|
|
reference to the <a href="#S2.2.2" shape="rect">root rule</a>.</p>
|
|
<pre class="xml" xml:space="preserve">
|
|
<ruleref uri="http://grammar.example.com/ngram.xml#StartSymbol"/>
|
|
<ruleref uri="http://grammar.example.com/ngram.xml"/>
|
|
</pre></blockquote>
|
|
<h3 id="id-S2.3"><a id="S2.3" name="S2.3" shape="rect">2.3
|
|
Sequences and Encapsulation</a></h3>
|
|
<p>A <em>sequence</em> of legal rule expansions is itself a
|
|
<a href="#S2" shape="rect">legal rule expansion</a>.</p>
|
|
<p>The sequence of rule expansions implies the temporal order in
|
|
which the expansions must be detected by the <a href="#S1.1" shape=
|
|
"rect">user agent</a>. This constraint applies to sequences of
|
|
tokens, sequences of rule references, sequences of tags,
|
|
parentheticals and all combinations of these rule expansions.</p>
|
|
<p>Both the ABNF Form and XML Form provide syntax for encapsulating
|
|
any expansion. This is used, for example, to attach a <a href=
|
|
"#S2.5" shape="rect">repeat operator</a>, a <a href="#S2.7" shape=
|
|
"rect">language identifier</a> or to ensure correct <a href="#S2.8"
|
|
shape="rect">precedence</a> in parsing (ABNF only).</p>
|
|
<blockquote>
|
|
<h4 id="id-S2.3-abnf">ABNF Form</h4>
|
|
<p>A sequence of legal expansions separated by <a href=
|
|
"#term-whitespace" shape="rect">white space</a> is a legal
|
|
expansion.</p>
|
|
<p>A legal expansion surrounded by parentheses ('(' and ')') is a
|
|
legal expansion.</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
this is a test // sequence of tokens
|
|
$action $object // sequence of rule references
|
|
the $object is $color // sequence of tokens and rule references
|
|
(fly to $city) // parentheses for encapsulation
|
|
</pre>
|
|
<h5>Special cases</h5>
|
|
<p>An empty parenthetical is legal as is a parenthetical containing
|
|
only <a href="#term-whitespace" shape="rect">white space</a>; e.g.
|
|
'()' or '( )'. Both forms are equivalent to <a href="#S2.2.3"
|
|
shape="rect">$NULL</a> and a grammar processor will behave as if
|
|
the parenthetical were not present.</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
// equivalent sequences
|
|
phone home
|
|
phone ( ) home
|
|
</pre>
|
|
<h4 id="id-S2.3-xml">XML Form</h4>
|
|
<p>A sequence of XML rule expansion elements (
|
|
<code><ruleref></code>, <code><item></code>,
|
|
<code><one-of></code>, <code><token></code>
|
|
<code><tag></code>) and CDATA sections containing space
|
|
separated tokens must be recognized in temporal sequence. (The only
|
|
exception is where one or more "item" elements appear within a
|
|
<a href="#S2.4" shape="rect"><code>one-of</code></a> element.)</p>
|
|
<p>An <code>item</code> element can surround any expansion to
|
|
permit a <a href="#S2.5" shape="rect">repeat</a> attribute or
|
|
<a href="#S2.7" shape="rect">language identifier</a> to be
|
|
attached. The <code>weight</code> attribute of <code>item</code> is
|
|
ignored unless the element appears within a <code>one-of</code>
|
|
element.</p>
|
|
<pre class="xml" xml:space="preserve">
|
|
<!-- sequence of tokens -->
|
|
this is a test
|
|
|
|
<!--sequence of rule references-->
|
|
<ruleref uri="#action"/> <ruleref uri="#object"/>
|
|
|
|
<!--sequence of tokens and rule references-->
|
|
the <ruleref uri="#object"/> is <ruleref uri="#color"/>
|
|
|
|
<!-- sequence container -->
|
|
<item>fly to <ruleref uri="#city"/> </item>
|
|
</pre>
|
|
<h5>Special cases</h5>
|
|
<p>An empty item element is legal as is an item element containing
|
|
only <a href="#term-whitespace" shape="rect">white space</a>. Both
|
|
forms are equivalent to a <a href="#S2.2.3" shape="rect">NULL</a>
|
|
reference and a grammar processor will behave as if the item were
|
|
not present.</p>
|
|
<pre class="xml" xml:space="preserve">
|
|
<!-- equivalent sequences -->
|
|
phone home
|
|
phone <item/> home
|
|
phone <item></item> home
|
|
phone <item> </item> home
|
|
</pre></blockquote>
|
|
<h3 id="id-S2.4"><a id="S2.4" name="S2.4" shape="rect">2.4
|
|
Alternatives</a></h3>
|
|
<p>Any set of <em>alternative legal rule expansions</em> is itself
|
|
a <a href="#S2" shape="rect">legal rule expansion</a>. For input to
|
|
match a set of alternative rule expansions it must match one of the
|
|
set of alternative expansions. A set of alternatives must contain
|
|
one or more alternatives.</p>
|
|
<p>Any set of alternatives may be labeled with a <a href="#S2.7"
|
|
shape="rect">language attachment</a>. In the XML Form an <a href=
|
|
"#S2.7-xml" shape="rect"><code>xml:lang</code></a> attribute is
|
|
present on the <code>one-of</code> element. In the ABNF Form to
|
|
ensure correct precedence the set of alternatives must be <a href=
|
|
"#S2.3" shape="rect">delimited</a> by parentheses with the <a href=
|
|
"#S2.7-abnf" shape="rect">ABNF language attachment</a> immediately
|
|
following.</p>
|
|
<h4 id="id-S2.4.1"><a id="S2.4.1" name="S2.4.1" shape="rect">2.4.1
|
|
Weights</a></h4>
|
|
<p>A weight may be optionally provided for any number of
|
|
alternatives in an alternative expansion. Weights are simple
|
|
positive floating point values without exponentials. Legal formats
|
|
are <code>"n"</code>, <code>"n."</code>, <code>".n"</code> and
|
|
<code>"n.n"</code> where <code>"n"</code> is a sequence of one or
|
|
many digits.</p>
|
|
<p>A weight is nominally a multiplying factor in the likelihood
|
|
domain of a speech recognition search. A weight of 1.0 is
|
|
equivalent to providing no weight at all. A weight greater than
|
|
"1.0" positively biases the alternative and a weight less than
|
|
"1.0" negatively biases the alternative.</p>
|
|
<p><a href="#ref-jel98" shape="rect">[JEL98]</a> and <a href=
|
|
"#ref-rab93" shape="rect">[RAB93]</a> are informative references on
|
|
the topic of speech recognition technology and the underlying
|
|
statistical framework within which weights are applied.</p>
|
|
<p>Grammar authors and speech recognizer developers should be aware
|
|
of the following limitations upon the definition and application of
|
|
weights as outlined above.</p>
|
|
<ul>
|
|
<li>The application of weights to a speech recognition search is
|
|
under the internal control of the recognizer. There is no normative
|
|
or informative algorithm for applying weights. Furthermore, speech
|
|
recognition is a statistical process so consistent behavior cannot
|
|
be guaranteed.</li>
|
|
<li>Appropriate weights are difficult to determine for any specific
|
|
grammar and recognizer. Guessing weights does not always improve
|
|
speech recognition performance.</li>
|
|
<li>Effective weights are best obtained by study of real speech
|
|
input to a grammar. For example, a reasonable technique for
|
|
developing portable weights is to use weights that are correlated
|
|
with the occurrence counts of a set of alternatives.</li>
|
|
<li>Tuning weights for a particular recognizer does not guarantee
|
|
improved recognition performance on other speech recognizers.</li>
|
|
</ul>
|
|
<blockquote>
|
|
<h4 id="id-S2.4-abnf">ABNF Form</h4>
|
|
<p>A set of alternative choices is identified as a list of legal
|
|
expansions separated by the vertical bar symbol. If necessary, the
|
|
set of alternative choices may be delimited by parentheses.</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
Michael | Yuriko | Mary | Duke | $otherNames
|
|
(1 | 2 | 3)
|
|
</pre>
|
|
<p>A <a href="#S2.4.1" shape="rect"><code>weight</code></a> is
|
|
surrounded by forward slashes and placed before each item in the
|
|
alternatives list.</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
/10/ small | /2/ medium | large
|
|
/3.1415/ pie | /1.414/ root beer | /.25/ cola
|
|
</pre>
|
|
<h5>Special Cases</h5>
|
|
<p>It is legal for an alternative to be a reference to <a href=
|
|
"#S2.2.3" shape="rect">$NULL</a>, an empty parenthetical or a
|
|
single tag. In each case the input is equivalent to matching $NULL
|
|
and as a result the other alternatives are optional.</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
// Legal
|
|
$rule1 = word | $NULL;
|
|
$rule2 = () | word;
|
|
$rule3 = word | {<a href="#S1.4" shape="rect">TAG-CONTENT</a>};
|
|
</pre>
|
|
<p>An empty alternative (<a href="#term-whitespace" shape=
|
|
"rect">white space</a> only) is not legal.</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
// ILLEGAL
|
|
$rule1 = a | | b;
|
|
$rule2 = | b;
|
|
$rule3 = a |;
|
|
</pre>
|
|
<p>The following construct is interpreted as a single weighted
|
|
alternative.</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
// Legal
|
|
$rule1 = /2/ word;
|
|
$rule2 = /2/ {<a href="#S1.4" shape="rect">TAG-CONTENT</a>};
|
|
$rule3 = /2/ $NULL;
|
|
</pre>
|
|
<h4 id="id-S2.4-xml">XML Form</h4>
|
|
<p>The <code>one-of</code> element identifies a set of alternative
|
|
elements. Each alternative expansion is contained in a
|
|
<code>item</code> element. There must be at least one
|
|
<code>item</code> element contained within a <code>one-of</code>
|
|
element. <a href="#S2.4.1" shape="rect">Weights</a> are optionally
|
|
indicated by the <code>weight</code> attribute on the
|
|
<code>item</code> element.</p>
|
|
<pre class="xml" xml:space="preserve">
|
|
<one-of>
|
|
<item>Michael</item>
|
|
<item>Yuriko</item>
|
|
<item>Mary</item>
|
|
<item>Duke</item>
|
|
<item><ruleref uri="#otherNames"/></item>
|
|
</one-of>
|
|
|
|
<one-of><item>1</item> <item>2</item> <item>3</item></one-of>
|
|
|
|
<one-of>
|
|
<item weight="10">small</item>
|
|
<item weight="2">medium</item>
|
|
<item>large</item>
|
|
</one-of>
|
|
|
|
<one-of>
|
|
<item weight="3.1415">pie</item>
|
|
<item weight="1.414">root beer</item>
|
|
<item weight=".25">cola</item>
|
|
</one-of>
|
|
</pre>
|
|
<h5>Special cases</h5>
|
|
<p>A <code>one-of</code> element containing a single item is legal
|
|
and requires that input match the single item. The single item may
|
|
be optionally weighted.</p>
|
|
<pre class="xml" xml:space="preserve">
|
|
<one-of>
|
|
<item>word</item>
|
|
</one-of>
|
|
|
|
<one-of>
|
|
<item weight="2.0">word</item>
|
|
</one-of>
|
|
</pre>
|
|
<p>Is it legal for an alternative to be a reference to <a href=
|
|
"#S2.2.3" shape="rect">NULL</a>, an empty item or a single tag. In
|
|
each case the input is equivalent to matching NULL and as a result
|
|
the other alternatives are optional.</p>
|
|
<pre class="xml" xml:space="preserve">
|
|
<one-of>
|
|
<item>word</item>
|
|
<item/>
|
|
</one-of>
|
|
<one-of>
|
|
<item>word</item>
|
|
|
|
<span><item> <ruleref special="NULL"/> </item></span>
|
|
</one-of>
|
|
<one-of>
|
|
<item>word</item>
|
|
<item> <tag><a href="#S1.4" shape=
|
|
"rect">TAG-CONTENT</a></tag> </item>
|
|
</one-of>
|
|
</pre></blockquote>
|
|
<h3 id="id-S2.5"><a id="S2.5" name="S2.5" shape="rect">2.5
|
|
Repeats</a></h3>
|
|
<p>Any <em>repeated legal rule expansion</em> is itself a <a href=
|
|
"#S2" shape="rect">legal rule expansion</a>.</p>
|
|
<p>Operators are provided that define a legal rule expansion as
|
|
being another sub-expansion that is optional, that is repeated zero
|
|
or more times, that is repeated one or more times, or that is
|
|
repeated some range of times.</p>
|
|
<table border="1" cellpadding="3" summary=
|
|
"Legal Values for Repeat Attribute">
|
|
<tr>
|
|
<td align="center" colspan="1" rowspan="1"><b><em>ABNF
|
|
Form</em><br clear="none" />
|
|
Example</b></td>
|
|
<td align="center" colspan="1" rowspan="1"><b><em>XML
|
|
Form</em><br clear="none" />
|
|
Example</b></td>
|
|
<td colspan="1" rowspan="1"><b>Behavior</b></td>
|
|
</tr>
|
|
<tr>
|
|
<td align="center" colspan="1" rowspan="1">
|
|
<em><n></em><br clear="none" />
|
|
<6></td>
|
|
<td align="center" colspan="1" rowspan="1">
|
|
<em>repeat="n"</em><br clear="none" />
|
|
repeat="6"</td>
|
|
<td colspan="1" rowspan="1">The contained expansion is repeated
|
|
exactly "n" times. "n" must be "0" or a positive integer.</td>
|
|
</tr>
|
|
<tr>
|
|
<td align="center" colspan="1" rowspan="1">
|
|
<em><m-n></em><br clear="none" />
|
|
<4-6></td>
|
|
<td align="center" colspan="1" rowspan="1">
|
|
<em>repeat="m-n"</em><br clear="none" />
|
|
repeat="4-6"</td>
|
|
<td colspan="1" rowspan="1">The contained expansion is repeated
|
|
between "m" and "n" times (inclusive). "m" and "n" must both be "0"
|
|
or a positive integer and "m" must be less than or equal to
|
|
"n".</td>
|
|
</tr>
|
|
<tr>
|
|
<td align="center" colspan="1" rowspan="1">
|
|
<em><m-></em><br clear="none" />
|
|
<3-></td>
|
|
<td align="center" colspan="1" rowspan="1">
|
|
<em>repeat="m-"</em><br clear="none" />
|
|
repeat="3-"</td>
|
|
<td colspan="1" rowspan="1">The contained expansion is repeated "m"
|
|
times or more (inclusive). "m" must be "0" or a positive integer.
|
|
For example, "3-" declares that the contained expansion can occur
|
|
three, four, five or more times.</td>
|
|
</tr>
|
|
<tr>
|
|
<td align="center" colspan="1" rowspan="1"><0-1><br clear=
|
|
"none" />
|
|
[...]</td>
|
|
<td align="center" colspan="1" rowspan="1">repeat="0-1"</td>
|
|
<td colspan="1" rowspan="1">The contained expansion is
|
|
optional.</td>
|
|
</tr>
|
|
</table>
|
|
<h5>Common Repeats</h5>
|
|
<p>As indicated in the table above, an expansion that can occur 0-1
|
|
times is optional. Because optionality is such a common form the
|
|
ABNF syntax provides square brackets as a special operator for
|
|
representing optionality.</p>
|
|
<p>A repeat of "0-" indicates that an expansion can occur zero
|
|
times, once or any number of multiple times. In regular expression
|
|
languages this is often represented by the <em>Kleene star</em>
|
|
('*') which is reserved but not used in ABNF.</p>
|
|
<p>A repeat of "1-" indicates that an expansion can occur once or
|
|
any number of multiple times. In regular expression languages this
|
|
is often represented by the <em>positive closure</em> ('+') which
|
|
is reserved but not used in ABNF.</p>
|
|
<p>Although both ABNF and XML support a grammar that permits an
|
|
unbounded number of input tokens it is not the case that users will
|
|
speak indefinitely. Speech recognition can perform more effectively
|
|
if the author indicates a more limited range of repeat
|
|
occurrences.</p>
|
|
<h5>Special Cases</h5>
|
|
<p>Where a number of possible repetitions (e.g. <m-> or
|
|
<m-n> (n > 0) but not <0>) is expressed on a
|
|
construct whose only content is one or more <a href="#S2.6" shape=
|
|
"rect">tag</a> elements, the behavior of the grammar processor is
|
|
not defined and will be specific to individual implementations.</p>
|
|
<p>Any number of non-optional repetitions (e.g., <m-n>;
|
|
m>0) of <a href="#S2.2.3" shape="rect">VOID</a> is equivalent to
|
|
a single <a href="#S2.2.3" shape="rect">VOID</a>.</p>
|
|
<p>The behavior of a grammar processor in handling any number of
|
|
repetitions of <a href="#S2.2.3" shape="rect">NULL</a> is not
|
|
defined and will be specific to individual implementations.</p>
|
|
<p>If the number of repetitions for any expansion can be only zero
|
|
(i.e. <0> or <0-0>) then the expansion is equivalent to
|
|
<a href="#S2.2.3" shape="rect">NULL</a>.</p>
|
|
<h4 id="id-S2.5.1"><a id="S2.5.1" name="S2.5.1" shape="rect">2.5.1
|
|
Repeat Probabilities</a></h4>
|
|
<p>Any repeat operator may specify an optional repeat probability.
|
|
The value indicates the probability of successive repetition of the
|
|
repeated expansion.</p>
|
|
<p>A repeat probability value must be in the floating pointing
|
|
range of "0.0" to "1.0" (inclusive). Values outside this range are
|
|
illegal. The floating point format is one of "n", "n.", "n.nnnn",
|
|
".nnnn" (with any number of digits after the dot).</p>
|
|
<p>Note: repeat probabilities and <a href="#S2.4.1" shape=
|
|
"rect">weights</a> are different logical entities and have a
|
|
different impact upon a speech recognition search.</p>
|
|
<p>Informative example: A simple example is an optional expansion
|
|
(zero or one occurrences) with a probability — say "0.6". The
|
|
grammar indicates that the chance that the expansion will be
|
|
matched is 60% and that the chance that the expansion will not be
|
|
present is 40%.</p>
|
|
<p>When no maximum is specified in a range (m-) the probabilities
|
|
decay exponentially.</p>
|
|
<p>Grammar authors and speech recognizer developers should be aware
|
|
of the following limitations upon the definition and application of
|
|
repeat probabilities as outlined above.</p>
|
|
<ul>
|
|
<li>The application of repeat probabilities to a speech recognition
|
|
search is under the internal control of the recognizer. There is no
|
|
specified algorithm for applying repeat probabilities in a speech
|
|
recognition processor so consistent behavior cannot be
|
|
guaranteed.</li>
|
|
<li>Appropriate repeat probabilities are often difficult to
|
|
determine for any specific grammar and recognizer. Guessing repeat
|
|
probabilities does not always improve speech recognition
|
|
performance.</li>
|
|
<li>Appropriate repeat probabilities are best obtained by study of
|
|
statistical patterns of real speech input. Tuning repeat
|
|
probabilities for a particular recognizer does not guarantee
|
|
improved recognition performance on other speech recognizers.</li>
|
|
</ul>
|
|
<p>Useful references on statistical models of speech recognition
|
|
include <a href="#ref-jel98" shape="rect">[JEL98]</a> and <a href=
|
|
"#ref-rab93" shape="rect">[RAB93]</a>.</p>
|
|
<blockquote>
|
|
<h4 id="id-S2.5-abnf">ABNF Form</h4>
|
|
<p>The following are postfix operators: <code><m-n>
|
|
<m-> <m></code>. A postfix operator is logically
|
|
attached to the preceding expansion. Postfix operators have high
|
|
precedence and so are tightly bound to the immediately preceding
|
|
expansion (see <a href="#S2.8" shape="rect">Section 2.8</a>).</p>
|
|
<p>Optional expansions may be delimited by square brackets:
|
|
<code>[expansion]</code>. Alternatively, an optional expansion is
|
|
indicated by the postfix operator "<code><0-1></code>".</p>
|
|
<p>The following symbols are <em>reserved</em> for future use in
|
|
ABNF: '*', '+', '?'. These symbols must not be used at any place in
|
|
a grammar where the syntax currently permits a repeat operator.</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
// the token "very" is optional
|
|
[very]
|
|
very <0-1>
|
|
|
|
// the rule reference $digit can occur zero, one or many times
|
|
|
|
$digit <0->
|
|
|
|
// the rule reference $digit can occur one or more times
|
|
|
|
$digit <1->
|
|
|
|
// the rule reference $digit can occur four, five or six times
|
|
$digit <4-6>
|
|
|
|
// the rule reference $digit can occur ten or more times
|
|
$digit <10->
|
|
|
|
// Examples of the following expansion
|
|
// "pizza"
|
|
// "big pizza with pepperoni"
|
|
// "very big pizza with cheese and pepperoni"
|
|
[[very] big] pizza ([with | and] $topping) <0->
|
|
</pre>
|
|
<p>Repeat probabilities are only supported in the range form. The
|
|
probability is delimited by slash characters and contained within
|
|
the angle brackets: <code><m-n /prob/></code> and
|
|
<code><m- /prob/></code>.</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
// the token "very" is optional and is 60% likely to occur
|
|
// and 40% likely to be absent in input
|
|
very <0-1 /0.6/>
|
|
|
|
// the rule reference $digit must occur two to four times
|
|
// with 80% probability of recurrence
|
|
$digit <2-4 /.8/>
|
|
</pre>
|
|
<h4 id="id-S2.5-xml">XML Form</h4>
|
|
<p>The <code>item</code> element has a <code>repeat</code>
|
|
attribute that indicates the number of times the contained
|
|
expansion may be repeated. The following example illustrates the
|
|
accepted values of the attribute.</p>
|
|
<pre class="xml" xml:space="preserve">
|
|
<!-- the token "very" is optional -->
|
|
|
|
<item repeat="0-1">very</item>
|
|
|
|
<!-- the rule reference to digit can occur zero, one or many times -->
|
|
|
|
<item repeat="0-"> <ruleref uri="#digit"/> </item>
|
|
|
|
<!-- the rule reference to digit can occur one or more times -->
|
|
|
|
<item repeat="1-"> <ruleref uri="#digit"/> </item>
|
|
|
|
<!-- the rule reference to digit can occur four, five or six times -->
|
|
<item repeat="4-6"> <ruleref uri="#digit"/> </item>
|
|
|
|
<!-- the rule reference to digit can occur ten or more times -->
|
|
<item repeat="10-"> <ruleref uri="#digit"/> </item>
|
|
|
|
<!-- Examples of the following expansion -->
|
|
<!-- "pizza" -->
|
|
<!-- "big pizza with pepperoni" -->
|
|
<!-- "very big pizza with cheese and pepperoni" -->
|
|
|
|
<item repeat="0-1">
|
|
<item repeat="0-1"> very </item>
|
|
big
|
|
</item>
|
|
pizza
|
|
<item repeat="0-">
|
|
<item repeat="0-1">
|
|
<one-of>
|
|
<item>with</item>
|
|
<item>and</item>
|
|
</one-of>
|
|
</item>
|
|
<ruleref uri="#topping"/>
|
|
</item>
|
|
</pre>
|
|
<p>The <code>repeat-prob</code> on the item element carries the
|
|
repeat probability. Repeat probabilities are supported on any item
|
|
element but are ignored if the repeat attribute is not also
|
|
specified.</p>
|
|
<pre class="xml" xml:space="preserve">
|
|
<-- The token "very" is optional and is 60% likely to occur. -->
|
|
<-- Means 40% chance that "very" is absent in input -->
|
|
<item repeat="0-1" repeat-prob="0.6">very</item>
|
|
|
|
<-- The rule reference to digit must occur two to four times -->
|
|
<-- with 80% probability of recurrence. -->
|
|
<item repeat="2-4" repeat-prob=".8">
|
|
<ruleref uri="#digit"/>
|
|
</item>
|
|
</pre></blockquote>
|
|
<h3 id="id-S2.6"><a id="S2.6" name="S2.6" shape="rect">2.6
|
|
Tags</a></h3>
|
|
<p>A <em>tag</em> is a <a href="#S2" shape="rect">legal rule
|
|
expansion</a> <span>(a tag can also be declared in the grammar
|
|
header - see <a href="#S4.1" shape="rect">S4.1</a>)</span>.</p>
|
|
<p>A <code>tag</code> is an <em>arbitrary string</em> that may be
|
|
included inline within any legal rule expansion. Any number of tags
|
|
may be included inline within a rule expansion.</p>
|
|
<p>Tags do not affect the legal word patterns defined by the
|
|
grammars or the process of recognizing speech or other input given
|
|
a grammar.</p>
|
|
<p>Tags may contain content for <a href="#S1.4" shape=
|
|
"rect">semantic interpretation</a>. The semantic interpretation
|
|
processes may affect the recognition result.</p>
|
|
<p><a href="#S2.7" shape="rect">Language attachments</a> have no
|
|
effect upon tags.</p>
|
|
<p>The <a href="#S4.8" shape="rect">tag format declaration</a>
|
|
indicates the content type of all tags in a grammar.</p>
|
|
<h5>Special Cases</h5>
|
|
<p>It is legal to use a <code>tag</code> as a stand-alone
|
|
expansion. For example, a rule may expand to a single tag and no
|
|
tokens.</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
$rule = {<a href="#S1.4" shape="rect">TAG-CONTENT</a>};
|
|
</pre>
|
|
<pre class="xml" xml:space="preserve">
|
|
<rule id="rule"><tag><a href="#S1.4" shape=
|
|
"rect">TAG-CONTENT</a></tag></rule>
|
|
</pre>
|
|
<blockquote>
|
|
<h4 id="id-S2.6-abnf">ABNF Form</h4>
|
|
<p>A <code>tag</code> is delimited by either a pair of opening and
|
|
closing curly brackets — '{' and '}' — or by the following
|
|
3-character sequences which are considered very unlikely to occur
|
|
within a tag — '{!{' and '}!}'. A tag delimited by single curly
|
|
brackets cannot contain the single closing curly bracket character
|
|
('}'). A tag delimited by the 3-character sequence cannot contain
|
|
the closing 3-character sequence ('}!}').</p>
|
|
<p>The tag content is all text between the opening and closing
|
|
character sequences including leading and trailing <a href=
|
|
"#term-whitespace" shape="rect">white space</a>. The contents of the
|
|
tag are not parsed by the grammar processor.</p>
|
|
<p>Tag precedence is the same as for rule references and tokens. In
|
|
the first example below there is a sequence of six space-separated
|
|
expansions (3 tokens, a tag, a token and a tag). In the second
|
|
example, the alternative is a choice between a sequence containing
|
|
a token and a tag or a sequence containing a rule reference and a
|
|
tag.</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
$rule1 = this is a {<a href="#S1.4" shape=
|
|
"rect">TAG-CONTENT-1</a>} test {<a href="#S1.4" shape=
|
|
"rect">TAG-CONTENT-2</a>};
|
|
|
|
$rule2 = open {<a href="#S1.4" shape=
|
|
"rect">TAG-CONTENT-1</a>} | $close {<a href="#S1.4" shape=
|
|
"rect">TAG-CONTENT-2</a>};
|
|
|
|
$rule3 = {!{ a simple tag containing { and } needs no escaping }!};
|
|
</pre>
|
|
<h4 id="id-S2.6-xml">XML Form</h4>
|
|
<p>A <code>tag</code> element can be a direct child of the
|
|
<code>item</code> and <code>rule</code> elements. The content of
|
|
<code>tag</code> is CDATA.</p>
|
|
<pre class="xml" xml:space="preserve">
|
|
<rule id="rule1">this is a <tag><a href="#S1.4" shape=
|
|
"rect">TAG-CONTENT-1</a></tag> test <tag><a href=
|
|
"#S1.4" shape="rect">TAG-CONTENT-2</a></tag> </rule>
|
|
|
|
<rule id="rule2">
|
|
<one-of>
|
|
<item> open <tag><a href="#S1.4" shape=
|
|
"rect">TAG-CONTENT-1</a></tag> </item>
|
|
<item> <ruleref uri="#close"/> <tag><a href="#S1.4"
|
|
shape="rect">TAG-CONTENT-2</a></tag> </item>
|
|
</one-of>
|
|
</rule>
|
|
</pre></blockquote>
|
|
<h3 id="id-S2.7"><a id="S2.7" name="S2.7" shape="rect">2.7
|
|
Language</a></h3>
|
|
<p>Any <a href="#S2" shape="rect">legal rule expansion</a> that has
|
|
an attached <a href="#term-language" shape="rect">language
|
|
identifier</a> is itself a legal rule expansion. Both the ABNF Form
|
|
and the XML Form permit a legal language identifier to be attached
|
|
to any <a href="#S2.1" shape="rect">token</a>, <a href="#S2.3"
|
|
shape="rect">sequence</a> or <a href="#S2.4" shape="rect">set of
|
|
alternatives</a> <span>(Note that <a href="#S2.2" shape="rect">rule
|
|
reference</a> does not permit a language identifier to be
|
|
attached)</span>. The syntax for the <a href="#S2.7-abnf" shape=
|
|
"rect">ABNF Form</a> and for the <a href="#S2.7-xml" shape=
|
|
"rect">XML Form</a> are provided below.</p>
|
|
<p>The language declaration for a rule expansion affects only the
|
|
contained content. Moreover, the language declaration affects only
|
|
the handling of <a href="#S2.1" shape="rect">tokens</a> in the
|
|
contained content and does not affect <a href="#S2.6" shape=
|
|
"rect">tags</a> or <a href="#S2.2" shape="rect">rule
|
|
references</a>. The application of language to token handling and
|
|
particularly to pronunciation lookup is described in <a href=
|
|
"#S2.1" shape="rect">Section 2.1</a>.</p>
|
|
<p>By default a grammar is a single language document with a
|
|
<a href="#term-language" shape="rect">language identifier</a>
|
|
provided in the <a href="#S4.5" shape="rect">language
|
|
declaration</a> in the <a href="#S4.1" shape="rect">grammar
|
|
header</a> (see <a href="#S4.5" shape="rect">Section 4.5</a>). All
|
|
tokens within that grammar, unless otherwise declared, will be
|
|
handled according to the grammar's language.</p>
|
|
<p>In situations where applications target a multilingual user
|
|
community, grammars that contain words in more than one language
|
|
may be needed. For example, in response to a prompt such as:
|
|
<em>"Do you want to talk to André Prévost?"</em> (a
|
|
combination of an English sentence with a French name), the
|
|
response may be either <em>"yes"</em> or <em>"oui"</em>.</p>
|
|
<p>The Speech Recognition Grammar Specification permits one grammar
|
|
to collect input from more than one language. The specification
|
|
also permits multiple grammars each with a separate single language
|
|
to be used in parallel. The specification also permits a single
|
|
input utterance to contain more than one language. Finally, the
|
|
specification permits any combination of the above: for example,
|
|
parallel grammars each with multi-lingual capability.</p>
|
|
<p>Not all user agents are required to support all languages, or
|
|
indeed any or all of the multi-lingual capabilities. The
|
|
conformance requirements regarding multi-lingual support for XML
|
|
Form grammar processors and ABNF Form grammar processors are the
|
|
same and are laid out in <a href="#S5.4" shape="rect">Section
|
|
5.4</a> and <a href="#S5.6" shape="rect">Section 5.6</a>
|
|
respectively.</p>
|
|
<p>There is a related challenge for multilingual applications that
|
|
deal with proper names (people, streets, companies, etc.) that may
|
|
be spoken with different pronunciations or accents depending upon
|
|
the language of origin and the speaking language. It is often
|
|
impossible to predict the language that users will use to pronounce
|
|
certain tokens. In fact, users may actually use different languages
|
|
for different words in the same sentence, and in unpredictable
|
|
ways. For instance, the name "Robert Jones" might be pronounced by
|
|
a French-speaking user using the French pronunciation for "Robert"
|
|
but an English pronunciation for "Jones", whereas a mono-lingual
|
|
English speaker would use the English pronunciation for both
|
|
words.</p>
|
|
<p><em>Language scoping:</em> language declarations are scoped
|
|
locally to a document and to a rule definition. In XML terminology,
|
|
the language attribute is inherited down the document tree. Where a
|
|
language change encompasses a reference to another grammar, the
|
|
referenced rule and its containing grammar define the language of
|
|
the reference expansion. The language in effect at the point of the
|
|
rule reference does not have any effect upon the referenced
|
|
rule.</p>
|
|
<p><em>Language and results:</em> The language used in the
|
|
recognition of a token is not considered a part of the speech
|
|
result even in the case that a language declaration is associated
|
|
with a token.</p>
|
|
<blockquote>
|
|
<h4 id="id-S2.7-abnf"><a id="S2.7-abnf" name="S2.7-abnf" shape=
|
|
"rect">ABNF Form</a></h4>
|
|
<p>In the ABNF Form a <a href="#term-language" shape=
|
|
"rect">language identifier</a> may be right-attached to any
|
|
<a href="#S2" shape="rect">legal rule expansion</a> <span>except
|
|
<a href="#S2.2" shape="rect">rule reference</a></span>. The
|
|
attachment is an exclamation point character ('!') followed by a
|
|
legal language identifier without intervening <a href=
|
|
"#term-whitespace" shape="rect">white space</a>.</p>
|
|
<p>The language attachment has higher <a href="#S2.8" shape=
|
|
"rect">precedence</a> than <a href="#S2.3" shape=
|
|
"rect">sequences</a> or <a href="#S2.4" shape=
|
|
"rect">alternatives</a>. To attach a language to these rule
|
|
expansion types the expansion should be delimited by parentheses
|
|
(see <a href="#S2.3" shape="rect">Section 2.3</a>).</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
#ABNF 1.0 ISO-8859-1;
|
|
|
|
// Default grammar language is US English
|
|
language en-US;
|
|
|
|
// Single language attachment to tokens
|
|
// Note that "fr-CA" (Canadian French) is applied to only
|
|
// the word "oui" because of precedence rules
|
|
$yes = yes | oui!fr-CA;
|
|
|
|
// Single language attachment to an expansion
|
|
$people1 = (Michel Tremblay | André Roy)!fr-CA;
|
|
|
|
// Handling language-specific pronunciations of the same word
|
|
// A capable speech recognizer will listen for Mexican Spanish and
|
|
// US English pronunciations.
|
|
$people2 = Jose!en-US; | Jose!es-MX;
|
|
|
|
/**
|
|
* Multi-lingual input possible
|
|
* @example may I speak to André Roy
|
|
* @example may I speak to Jose
|
|
*/
|
|
public $request = may I speak to ($people1 | $people2);
|
|
</pre>
|
|
<h4 id="id-S2.7-xml"><a id="S2.7-xml" name="S2.7-xml" shape=
|
|
"rect">XML Form</a></h4>
|
|
<p>XML 1.0 <a href="#ref-xml" shape="rect">[XML §2.12]</a>
|
|
defines the <a href=
|
|
"http://www.w3.org/TR/2000/REC-xml-20001006#sec-lang-tag" shape=
|
|
"rect"><code>xml:lang</code></a> attribute for language
|
|
identification. The attribute provides a single <a href=
|
|
"#term-language" shape="rect">language identifier</a> for the
|
|
content of the element on which it appears. The
|
|
<code>xml:lang</code> attribute may be attached to <a href="#S2.4"
|
|
shape="rect"><code>one-of</code></a> , <a href="#S2.1" shape=
|
|
"rect"><code>token</code></a> and <a href="#S2.3" shape=
|
|
"rect"><code>item</code></a>. It applies the token handling of
|
|
scoped tokens.</p>
|
|
<pre class="xml" xml:space="preserve">
|
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
|
|
|
<!DOCTYPE grammar PUBLIC "-//W3C//DTD GRAMMAR 1.0//EN"
|
|
"http://www.w3.org/TR/speech-grammar/grammar.dtd">
|
|
|
|
<!-- the default grammar language is US English -->
|
|
<grammar xmlns="http://www.w3.org/2001/06/grammar"
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://www.w3.org/2001/06/grammar
|
|
http://www.w3.org/TR/speech-grammar/grammar.xsd"
|
|
xml:lang="en-US" version="1.0">
|
|
|
|
<!--
|
|
single language attachment to tokens
|
|
"yes" inherits US English language
|
|
"oui" is Canadian French language
|
|
-->
|
|
<rule id="yes">
|
|
<one-of>
|
|
<item>yes</item>
|
|
<item xml:lang="fr-CA">oui</item>
|
|
</one-of>
|
|
</rule>
|
|
|
|
<!-- Single language attachment to an expansion -->
|
|
<rule id="people1">
|
|
<one-of xml:lang="fr-CA">
|
|
<item>Michel Tremblay</item>
|
|
<item>André Roy</item>
|
|
</one-of>
|
|
</rule>
|
|
|
|
<!--
|
|
Handling language-specific pronunciations of the same word
|
|
A capable speech recognizer will listen for Mexican Spanish
|
|
and US English pronunciations.
|
|
-->
|
|
<rule id="people2">
|
|
<one-of>
|
|
<item xml:lang="en-US">Jose</item>
|
|
<item xml:lang="es-MX">Jose</item>
|
|
</one-of>
|
|
</rule>
|
|
|
|
<!-- Multi-lingual input is possible -->
|
|
<rule id="request" scope="public">
|
|
<example> may I speak with André Roy </example>
|
|
<example> may I speak with Jose </example>
|
|
|
|
may I speak with
|
|
<one-of>
|
|
<item> <ruleref uri="#people1"/> </item>
|
|
<item> <ruleref uri="#people2"/> </item>
|
|
</one-of>
|
|
</rule>
|
|
</grammar>
|
|
</pre></blockquote>
|
|
<h3 id="id-S2.8"><a id="S2.8" name="S2.8" shape="rect">2.8
|
|
Precedence</a></h3>
|
|
<p>This section defines the precedence of the ABNF rule expansion
|
|
syntax. Because XML documents explicitly indicate structure there
|
|
is no ambiguity and thus a precedence definition is not required.
|
|
The precedence definitions for the ABNF Form are intended to
|
|
minimize the need for parentheses.</p>
|
|
<blockquote>
|
|
<h4 id="id-S2.8-abnf">ABNF Form</h4>
|
|
<p>The following is the ordering of precedence of rule expansions.
|
|
Parentheses may be used to explicitly control rule structure.</p>
|
|
<ol>
|
|
<li><a href="#S2.2" shape="rect">A rule reference</a>, a <a href=
|
|
"#S2.1" shape="rect">quoted token</a>, an <a href="#S2.1" shape=
|
|
"rect">unquoted token</a> or a <a href="#S2.6" shape=
|
|
"rect">tag</a>.</li>
|
|
<li><a href="#S2.3" shape="rect">Parentheses</a> ('(' and ')') for
|
|
grouping and square brackets ('[' and ']') for <a href="#S2.5"
|
|
shape="rect">optional grouping</a>.</li>
|
|
<li><a href="#S2.5" shape="rect">Repeat operator</a> (e.g.
|
|
"<code><0-1></code>") and <a href="#S2.7" shape=
|
|
"rect">language attachment</a> (e.g. "!en-AU") apply to the
|
|
tightest immediate preceding rule expansion. (To apply them to a
|
|
sequence or to alternatives, use `()' or `[]' for grouping.)</li>
|
|
<li><a href="#S2.3" shape="rect">Sequence</a> of rule
|
|
expansions.</li>
|
|
<li>Set of <a href="#S2.4" shape="rect">alternative rule
|
|
expansions</a> separated by vertical bars ('|') with optional
|
|
<a href="#S2.4.1" shape="rect">weights</a>.</li>
|
|
</ol>
|
|
<h4 id="id-S2.8-xml">XML Form</h4>
|
|
<p>None required. XML structure is explicit.</p>
|
|
</blockquote>
|
|
<h2 id="id-S3"><a id="S3" name="S3" shape="rect">3. Rule
|
|
Definitions</a></h2>
|
|
<ul>
|
|
<li class="tocline">3.1 <a href="#S3.1" shape="rect">Basic Rule
|
|
Definition</a></li>
|
|
<li class="tocline">3.2 <a href="#S3.2" shape="rect">Scoping of
|
|
Rule Definitions</a></li>
|
|
<li class="tocline">3.3 <a href="#S3.3" shape="rect">Example
|
|
Phrases</a></li>
|
|
</ul>
|
|
<p>A <em>rule definition</em> associates a legal <a href="#S2"
|
|
shape="rect">rule expansion</a> with a <em>rulename</em>. The rule
|
|
definition is also responsible for defining the <a href="#S3.2"
|
|
shape="rect"><em>scope</em></a> of the rule definition: whether it
|
|
is local to the grammar in which it is defined or whether it may be
|
|
referenced within other grammars. Finally, the rule definition may
|
|
additionally include documentation comments and other
|
|
pragmatics.</p>
|
|
<p>The rulename for each rule definition must be unique within a
|
|
grammar. The same rulename may be used in multiple grammars.</p>
|
|
<p>A rule definition is referenced by a URI in a <a href="#S2.2"
|
|
shape="rect">rule reference</a> with the rulename being represented
|
|
as the fragment identifier.</p>
|
|
<h3 id="id-S3.1"><a id="S3.1" name="S3.1" shape="rect">3.1 Basic
|
|
Rule Definition</a></h3>
|
|
<p>The core purpose of a rule definition is to associate a legal
|
|
rule expansion with a rulename.</p>
|
|
<p>A legal rulename in either the XML Form or ABNF Form is a
|
|
character sequence that:</p>
|
|
<ul>
|
|
<li>is an <a href=
|
|
"http://www.w3.org/TR/2000/REC-xml-20001006#NT-Name" shape=
|
|
"rect">XML Name</a> <a href="#ref-xml" shape="rect">[XML
|
|
§2.3]</a>,</li>
|
|
<li>and does not contain the following character '.', ':',
|
|
'-',</li>
|
|
<li>and is not the name of a <a href="#S2.2.3" shape="rect">special
|
|
rule</a> ("NULL", "VOID", "GARBAGE").</li>
|
|
</ul>
|
|
<p>Defined rulenames must be unique within a grammar. The <a href=
|
|
"#AppC" shape="rect">schema</a> enforces this by declaring the
|
|
rulename as an XML ID.</p>
|
|
<p>Rulenames are case-sensitive in both XML and ABNF grammars.
|
|
Exact string comparison is used to resolve rulename references.</p>
|
|
<p>A legal rulename cannot be one of the <a href="#S2.2.3" shape=
|
|
"rect">special rules</a>: specifically "NULL", "VOID" or
|
|
"GARBAGE".</p>
|
|
<blockquote>
|
|
<h4 id="id-S3.1-abnf">ABNF Form</h4>
|
|
<p>The rule definition consists of an optional scoping declaration
|
|
(explained in the next section) followed by a legal rule name, an
|
|
equals sign, a legal rule expansion and a closing semicolon. The
|
|
rule definition has one of the following legal forms:</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
<em>$ruleName = ruleExpansion;</em>
|
|
public <em>$ruleName = ruleExpansion;</em>
|
|
private <em>$ruleName = ruleExpansion;</em>
|
|
</pre>
|
|
<p>For example:</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
$city = Boston | "New York" | Madrid;
|
|
$command = $action $object;
|
|
</pre>
|
|
<h5>Special Cases</h5>
|
|
<p>An empty rule definition is illegal.</p>
|
|
<p>It is legal to define a rule that expands to empty parentheses
|
|
or <a href="#S2.2.3" shape="rect">$NULL</a> (equivalent forms). It
|
|
is legal to define a rule that expands to a single
|
|
<code>tag</code>.</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
// Legal
|
|
$rule = ();
|
|
$rule = $NULL;
|
|
$rule = {<a href="#S1.4" shape="rect">TAG-CONTENT</a>};
|
|
|
|
// ILLEGAL
|
|
$rule = ;
|
|
</pre>
|
|
<h4 id="id-S3.1-xml">XML Form</h4>
|
|
<p>A rule definition is represented by the <code>rule</code>
|
|
element. The <code>id</code> attribute of the element indicates the
|
|
name of the rule and must be unique within the grammar (this is
|
|
enforced by XML). The contents of the <code>rule</code> element may
|
|
be any legal rule expansion defined in <a href="#S2" shape=
|
|
"rect">Section 2</a>. The <code>scope</code> attribute is explained
|
|
in the next section.</p>
|
|
<pre class="xml" xml:space="preserve">
|
|
<rule id="city">
|
|
<one-of>
|
|
<item>Boston</item>
|
|
<item>"San Francisco"</item>
|
|
<item>Madrid</item>
|
|
</one-of>
|
|
</rule>
|
|
<rule id="command">
|
|
<ruleref uri="#action"/>
|
|
<ruleref uri="#object"/>
|
|
</rule>
|
|
</pre>
|
|
<h5>Special Cases</h5>
|
|
<p>It is not legal to define an empty rule element or a rule
|
|
element that contains only <a href="#term-whitespace" shape=
|
|
"rect">white space</a> CDATA.</p>
|
|
<p>It is legal to define a rule that expands to an empty item or to
|
|
a single rule reference to <a href="#S2.2.3" shape=
|
|
"rect">NULL</a>.</p>
|
|
<p>It is legal to define a rule that expands to a single
|
|
<code>tag</code> element.</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
<!-- Legal -->
|
|
<rule id="rule"><item/></rule>
|
|
<rule id="rule"><ruleref special="NULL"/></rule>
|
|
<rule id="rule"><tag><a href="#S1.4" shape=
|
|
"rect">TAG-CONTENT</a></tag></rule>
|
|
|
|
<!-- ILLEGAL -->
|
|
<rule id="rule"/>
|
|
<rule id="rule"></rule>
|
|
<rule id="rule"> </rule>
|
|
</pre></blockquote>
|
|
<h3 id="id-S3.2"><a id="S3.2" name="S3.2" shape="rect">3.2 Scoping
|
|
of Rule Definitions</a></h3>
|
|
<p>Each defined rule has a scope. The scope is either "private" or
|
|
"public". If not explicitly declared in a rule definition then the
|
|
scope defaults to "private".</p>
|
|
<p><span>A</span> public-scoped rule may be <span>explicitly</span>
|
|
<a href="#S2.2" shape="rect">referenced</a> <span>(using the
|
|
fragment identifier syntax of a URI)</span> in the rule definitions
|
|
of other grammars and in other non-grammar documents<span>.
|
|
A</span> private-scoped <span>rule</span> cannot be so referenced
|
|
<span>and is directly accessible only within its containing
|
|
grammar. A private rule may be explicitly referenced only by other
|
|
rules within the same grammar</span>.</p>
|
|
<p>Informative: grammar authors may consider the following guidance
|
|
when scoping the rules of a grammar.</p>
|
|
<ul>
|
|
<li>Grammar authoring shares many properties of programming.
|
|
Establishing contracts of an API is analogous to defining a set of
|
|
grammars and defining the public rules of a grammar each with
|
|
defined language behavior.</li>
|
|
<li>Consistent design and implementation of public rules promotes
|
|
grammar re-use and facilitates creation of grammar libraries.</li>
|
|
<li>Natural language grammars often require creation of many
|
|
internal "working" rules to create a smaller number of useful
|
|
external rules. Hiding working rules with private scope allows
|
|
revision of those rules without affecting other grammars that
|
|
reference the grammar. Hiding working rules also prevents
|
|
accidental mis-use of a working rule.</li>
|
|
<li>Grammar compilation resembles programming language compilation.
|
|
Making rules private allows advanced grammar compilers to perform
|
|
optimizations that cannot be applied when a rule is declared
|
|
public.</li>
|
|
</ul>
|
|
<blockquote>
|
|
<h4 id="id-S3.2-abnf">ABNF Form</h4>
|
|
<p>A rule definition may be annotated with the keywords "public" or
|
|
"private". If no scope is provided, the default is "private".</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
$town = Townsville | Beantown;
|
|
private $city = Boston | "New York" | Madrid;
|
|
public $command = $action $object;
|
|
</pre>
|
|
<h4 id="id-S3.2-xml">XML Form</h4>
|
|
<p>The <code>scope</code> attribute of the <code>rule</code>
|
|
element defines the scope of the rule definition. Defined values
|
|
are <code>public</code> and <code>private</code>. If omitted, the
|
|
default scope is <code>private</code>.</p>
|
|
<pre class="xml" xml:space="preserve">
|
|
<rule id="town">
|
|
<one-of>
|
|
<item>Townsville</item>
|
|
<item>Beantown</item>
|
|
</one-of>
|
|
</rule>
|
|
<rule id="city" scope="private">
|
|
<one-of>
|
|
<item>Boston</item>
|
|
<item>"San Francisco"</item>
|
|
<item>Madrid</item>
|
|
</one-of>
|
|
</rule>
|
|
<rule id="command" scope="public">
|
|
<ruleref uri="#action"/>
|
|
<ruleref uri="#object"/>
|
|
</rule>
|
|
</pre></blockquote>
|
|
<h3 id="id-S3.3"><a id="S3.3" name="S3.3" shape="rect">3.3 Example
|
|
Phrases</a></h3>
|
|
<p>It is often desirable to include examples of phrases that match
|
|
rule definitions along with the definition. Zero, one or many
|
|
example phrases may be provided for any rule definition. Because
|
|
the examples are explicitly marked, automated tools can be used for
|
|
regression testing and for generation of grammar documentation.</p>
|
|
<blockquote>
|
|
<h4 id="id-S3.3-abnf">ABNF Form</h4>
|
|
<p>A <a href="#S4.13" shape="rect">documentation comment</a> is a
|
|
C/C++/Java comment that starts with the sequence of characters
|
|
<code>/**</code> and which immediately precedes the relevant rule
|
|
definition. Zero or more <code>@example</code> tags may be
|
|
contained at the end of the documentation comment. The syntax
|
|
follows the <a href=
|
|
"http://java.sun.com/docs/books/jls/first_edition/html/18.doc.html#25995"
|
|
shape="rect">Tagged Paragraph</a> of a documentation comment of
|
|
the Java Programming Language <a href="#ref-java" shape=
|
|
"rect">[JAVA §18.4]</a>. The tokenization of the example
|
|
follows the tokenization and sequence rules defined in <a href=
|
|
"#S2.1" shape="rect">Section 2.1</a> and <a href="#S2.3" shape=
|
|
"rect">Section 2.3</a> respectively.</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
/**
|
|
* A simple directive to execute an action.
|
|
*
|
|
* @example open the window
|
|
* @example close the door
|
|
*/
|
|
public $command = $action $object;
|
|
</pre>
|
|
<h4 id="id-S3.3-xml">XML Form</h4>
|
|
<p>Any number of "example" elements may be provided as the initial
|
|
content within a "rule" element. The tokenization of the example
|
|
follows the tokenization and sequence rules defined in <a href=
|
|
"#S2.1" shape="rect">Section 2.1</a> and <a href="#S2.3" shape=
|
|
"rect">Section 2.3</a> respectively.</p>
|
|
<pre class="xml" xml:space="preserve">
|
|
<rule id="command" scope="public">
|
|
<!-- A simple directive to execute an action. -->
|
|
<example> open the window </example>
|
|
<example> close the door </example>
|
|
<ruleref uri="#action"/> <ruleref uri="#object"/>
|
|
</rule>
|
|
</pre></blockquote>
|
|
<h2 id="id-S4"><a id="S4" name="S4" shape="rect">4. Grammar
|
|
Documents</a></h2>
|
|
<p>A conforming stand-alone grammar document consists of a <a href=
|
|
"#S4.1" shape="rect">legal header</a> followed by a body consisting
|
|
of a set of legal <a href="#S3" shape="rect">rule definitions</a>.
|
|
All rules defined within that grammar are scoped within the
|
|
grammar's rulename namespace and each rulename must be <a href=
|
|
"#S3" shape="rect">legal and unique</a>.</p>
|
|
<p>It is legal for a grammar to define no rules. The grammar cannot
|
|
be used for processing input since it defines no patterns for
|
|
matching user input.</p>
|
|
<ul>
|
|
<li class="tocline">4.1 <a href="#S4.1" shape="rect">Grammar Header
|
|
Declarations</a></li>
|
|
<li class="tocline">4.2 <a href="#S4.2" shape="rect">ABNF
|
|
Self-Identifying Header</a></li>
|
|
<li class="tocline">4.3 <a href="#S4.3" shape="rect">XML Form
|
|
Prolog and Root Element</a></li>
|
|
<li class="tocline">4.4 <a href="#S4.4" shape="rect">Character
|
|
Encoding</a></li>
|
|
<li class="tocline">4.5 <a href="#S4.5" shape=
|
|
"rect">Language</a></li>
|
|
<li class="tocline">4.6 <a href="#S4.6" shape="rect">Mode</a></li>
|
|
<li class="tocline">4.7 <a href="#S4.7" shape="rect">Root
|
|
Rule</a></li>
|
|
<li class="tocline">4.8 <a href="#S4.8" shape="rect">Tag
|
|
Format</a></li>
|
|
<li class="tocline">4.9 <a href="#S4.9" shape="rect">Base URI</a>
|
|
<ul class="toc">
|
|
<li class="tocline">4.9.1 <a href="#S4.9.1" shape="rect">Resolving
|
|
Relative URIs</a></li>
|
|
</ul>
|
|
</li>
|
|
<li class="tocline">4.10 <a href="#S4.10" shape=
|
|
"rect">Pronunciation Lexicon</a></li>
|
|
<li class="tocline">4.11 <a href="#S4.11" shape="rect">Meta
|
|
Data</a>
|
|
<ul class="toc">
|
|
<li class="tocline">4.11.1 <a href="#S4.11.1" shape="rect">Meta and
|
|
HTTP-Equiv</a></li>
|
|
<li class="tocline">4.11.2 <a href="#S4.11.2" shape="rect">Metadata
|
|
(XML Only)</a></li>
|
|
</ul>
|
|
</li>
|
|
<li class="tocline"><span>4.12</span> <a href="#S4.12" shape=
|
|
"rect"><span>Tag</span></a></li>
|
|
<li class="tocline"><span>4.13</span> <a href="#S4.12" shape=
|
|
"rect">Comments</a></li>
|
|
<li class="tocline"><span>4.14</span> <a href="#S4.14" shape=
|
|
"rect">Grammar Fetching</a></li>
|
|
<li class="tocline"><span>4.15</span> <a href="#S4.15" shape=
|
|
"rect">ABNF Keywords</a></li>
|
|
</ul>
|
|
<h3 id="id-S4.1"><a id="S4.1" name="S4.1" shape="rect">4.1 Grammar
|
|
Header Declarations</a></h3>
|
|
<p>A legal stand-alone grammar header consists of a number of
|
|
required declarations and other optional declarations. In addition,
|
|
the ABNF Form and XML Form each have additional requirements and
|
|
capabilities of the header that are specific to each syntactic
|
|
form. The ordering of header declarations is also specific to the
|
|
two forms.</p>
|
|
<p>The table summarizes the information declared in a grammar
|
|
header and the appropriate representation in the ABNF Form and XML
|
|
Form.</p>
|
|
<table border="1" cellpadding="3" summary=
|
|
"Grammar Header Declarations" width="100%">
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><b>Declaration</b></td>
|
|
<td colspan="1" rowspan="1"><b>Status</b></td>
|
|
<td colspan="1" rowspan="1"><b>ABNF Form</b></td>
|
|
<td colspan="1" rowspan="1"><b>XML Form</b></td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1">Grammar version</td>
|
|
<td colspan="1" rowspan="1">Required</td>
|
|
<td colspan="1" rowspan="1"><a href="#S4.2" shape=
|
|
"rect">§4.2</a>: ABNF self-identifying header</td>
|
|
<td colspan="1" rowspan="1"><a href="#S4.3" shape=
|
|
"rect">§4.3</a>: <code>version</code> attribute on
|
|
<code>grammar</code> element</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1">XML Namespace</td>
|
|
<td colspan="1" rowspan="1">Required (XML only)</td>
|
|
<td colspan="1" rowspan="1">Not applicable</td>
|
|
<td colspan="1" rowspan="1"><a href="#S4.3" shape=
|
|
"rect">§4.3</a>: <code>xmlns</code> attribute on
|
|
<code>grammar</code> element</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1">Document type</td>
|
|
<td colspan="1" rowspan="1">Recommended (XML only)</td>
|
|
<td colspan="1" rowspan="1">Not applicable</td>
|
|
<td colspan="1" rowspan="1"><a href="#S4.3" shape=
|
|
"rect">§4.3</a>: XML DOCTYPE</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1">Character encoding</td>
|
|
<td colspan="1" rowspan="1">Recommended</td>
|
|
<td colspan="1" rowspan="1"><a href="#S4.4" shape=
|
|
"rect">§4.4</a>: ABNF self-identifying header</td>
|
|
<td colspan="1" rowspan="1"><a href="#S4.4" shape=
|
|
"rect">§4.4</a>: <code>encoding</code> attribute in XML
|
|
declaration</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1">Language</td>
|
|
<td colspan="1" rowspan="1">Required in voice mode<br clear=
|
|
"none" />
|
|
Ignored in DTMF mode</td>
|
|
<td colspan="1" rowspan="1"><a href="#S4.5" shape=
|
|
"rect">§4.5</a>: <code>language</code> declaration</td>
|
|
<td colspan="1" rowspan="1"><a href="#S4.5" shape=
|
|
"rect">§4.5</a>: <code>xml:lang</code> attribute on
|
|
<code>grammar</code> element</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1">Mode</td>
|
|
<td colspan="1" rowspan="1">Optional</td>
|
|
<td colspan="1" rowspan="1"><a href="#S4.6" shape=
|
|
"rect">§4.6</a>: <code>mode</code> declaration</td>
|
|
<td colspan="1" rowspan="1"><a href="#S4.6" shape=
|
|
"rect">§4.6</a>: <code>mode</code> attribute on
|
|
<code>grammar</code> element</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1">Root rule</td>
|
|
<td colspan="1" rowspan="1">Optional</td>
|
|
<td colspan="1" rowspan="1"><a href="#S4.7" shape=
|
|
"rect">§4.7</a>: <code>root</code> declaration</td>
|
|
<td colspan="1" rowspan="1"><a href="#S4.7" shape=
|
|
"rect">§4.7</a>: <code>root</code> attribute on
|
|
<code>grammar</code> element</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1">Tag format</td>
|
|
<td colspan="1" rowspan="1">Optional</td>
|
|
<td colspan="1" rowspan="1"><a href="#S4.8" shape=
|
|
"rect">§4.8</a>: <code>tag-format</code> declaration</td>
|
|
<td colspan="1" rowspan="1"><a href="#S4.8" shape=
|
|
"rect">§4.8</a>: <code>tag-format</code> attribute on
|
|
<code>grammar</code> element</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1">Base URI</td>
|
|
<td colspan="1" rowspan="1">Optional</td>
|
|
<td colspan="1" rowspan="1"><a href="#S4.9" shape=
|
|
"rect">§4.9</a>: <code>base</code> declaration</td>
|
|
<td colspan="1" rowspan="1"><a href="#S4.9" shape=
|
|
"rect">§4.9</a>: <code>xml:base</code> attribute on
|
|
<code>grammar</code> element</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1">Pronunciation lexicon</td>
|
|
<td colspan="1" rowspan="1">Optional. Multiple allowed.</td>
|
|
<td colspan="1" rowspan="1"><a href="#S4.10" shape=
|
|
"rect">§4.10</a>: <code>lexicon</code> declaration</td>
|
|
<td colspan="1" rowspan="1"><a href="#S4.10" shape=
|
|
"rect">§4.10</a>: <code>lexicon</code> element</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1">Metadata</td>
|
|
<td colspan="1" rowspan="1">Optional. Multiple allowed.</td>
|
|
<td colspan="1" rowspan="1"><a href="#S4.11.1" shape=
|
|
"rect">§4.11.1</a>: <code>meta</code> and
|
|
<code>http-equiv</code> declarations</td>
|
|
<td colspan="1" rowspan="1"><a href="#S4.11.1" shape=
|
|
"rect">§4.11.1</a>: <code>meta</code> element</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1">XML metadata</td>
|
|
<td colspan="1" rowspan="1">Optional. (XML Only)</td>
|
|
<td colspan="1" rowspan="1">Not applicable</td>
|
|
<td colspan="1" rowspan="1"><a href="#S4.11.2" shape=
|
|
"rect">§4.11.2</a>: <code>metadata</code> element</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1">Tag</td>
|
|
<td colspan="1" rowspan="1">Optional. Multiple allowed.</td>
|
|
<td colspan="1" rowspan="1"><a href="#S4.12" shape=
|
|
"rect">§4.12</a>: <code>tag</code> declaration</td>
|
|
<td colspan="1" rowspan="1"><a href="#S4.12" shape=
|
|
"rect">§4.12</a>: <code>tag</code> element</td>
|
|
</tr>
|
|
</table>
|
|
<a id="grammar-version" name="grammar-version" shape="rect"></a>
|
|
<p>A grammar that complies to this specification must declare the
|
|
version to be "1.0".</p>
|
|
<p>Note: the grammar version indicates the version of the
|
|
specification implemented by the grammar and is not for versioning
|
|
of the grammar content. A <a href="#S4.11.1" shape=
|
|
"rect"><code>meta</code></a> or <a href="#S4.11.2" shape=
|
|
"rect"><code>metadata</code></a> declaration may be used for
|
|
content versioning.</p>
|
|
<blockquote>
|
|
<h4 id="id-S4.1-abnf">ABNF Form: Header Summary</h4>
|
|
<p>A legal header for a stand-alone ABNF document consists of a
|
|
required <a href="#S4.2" shape="rect">ABNF self-identifying
|
|
header</a> including the grammar version and optional <a href=
|
|
"#S4.4" shape="rect">character encoding</a> followed by these
|
|
declarations in any order:</p>
|
|
<ul>
|
|
<li><a href="#S4.5" shape="rect">Language</a></li>
|
|
<li><a href="#S4.6" shape="rect">Mode</a></li>
|
|
<li><a href="#S4.7" shape="rect">Root rule</a></li>
|
|
<li><a href="#S4.8" shape="rect">Tag format</a></li>
|
|
<li><a href="#S4.9" shape="rect">Base URI</a></li>
|
|
<li><a href="#S4.10" shape="rect">Pronunciation lexicon</a> (any
|
|
number)</li>
|
|
<li><a href="#S4.11" shape="rect">Meta and http-equiv</a> (any
|
|
number)</li>
|
|
<li><a href="#S4.12" shape="rect">Tag</a> (any number)</li>
|
|
</ul>
|
|
<p><a href="#S4.13" shape="rect">ABNF comments</a> may appear
|
|
between the declarations in the ABNF header after the ABNF
|
|
self-identifying header.</p>
|
|
<p>The header declarations are followed by the <a href="#S3" shape=
|
|
"rect">rule definitions</a> of the grammar.</p>
|
|
<p>The following are two examples of ABNF headers. Note that
|
|
ordering of the declarations (except the ABNF self-identifying
|
|
header) is unimportant.</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
#ABNF 1.0 ISO-8859-1;
|
|
|
|
language en;
|
|
mode voice;
|
|
root $myRule;
|
|
tag-format FORMAT-STRING;
|
|
base <http://www.example.com/base-file-path>;
|
|
lexicon <http://www.example.com/lexicon.file>;
|
|
lexicon <http://www.example.com/strange-city-names.file>~<media-type>;
|
|
meta "Author" is "Stephanie Williams";
|
|
http-equiv "Date" is "Fri, 10 Feb 2002 17:27:21 GMT";
|
|
<span>{var x=1};</span>
|
|
</pre>
|
|
<pre class="abnf" xml:space="preserve">
|
|
#ABNF 1.0;
|
|
|
|
// A French Canadian grammar
|
|
language fr-CA;
|
|
|
|
// It's a speech grammar
|
|
mode voice;
|
|
|
|
// Here's the root rule
|
|
root $QuebecCities;
|
|
</pre></blockquote>
|
|
<blockquote>
|
|
<h4 id="id-S4.1-xml">XML Form: Header Summary</h4>
|
|
<p>A legal stand-alone XML Form grammar document consists of:</p>
|
|
<ol>
|
|
<li>Legal <a href="#S4.3" shape="rect">XML Prolog</a></li>
|
|
<li>Root grammar element with the following attributes
|
|
<ul>
|
|
<li><a href="#S4.3" shape="rect">XML namespace</a></li>
|
|
<li><a href="#S4.3" shape="rect">XML Schema attributes</a></li>
|
|
<li><a href="#S4.3" shape="rect">Version</a></li>
|
|
<li><a href="#S4.5" shape="rect">Language</a></li>
|
|
<li><a href="#S4.6" shape="rect">Mode</a></li>
|
|
<li><a href="#S4.7" shape="rect">Root rule</a></li>
|
|
<li><a href="#S4.8" shape="rect">Tag format</a></li>
|
|
<li><a href="#S4.9" shape="rect">Base URI</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><code>grammar</code> element containing any number of the
|
|
following elements in any order:
|
|
<ul>
|
|
<li><a href="#S4.10" shape="rect">Pronunciation lexicon</a> (any
|
|
number)</li>
|
|
<li><a href="#S4.11.1" shape="rect">Meta and HTTP-Equiv</a> (any
|
|
number)</li>
|
|
<li><a href="#S4.11.2" shape="rect">Metadata</a> (any number)</li>
|
|
<li><a href="#S4.12" shape="rect">Tag</a> (any number)</li>
|
|
</ul>
|
|
</li>
|
|
</ol>
|
|
<p><a href="#S3" shape="rect">Rule definitions</a> follow the
|
|
<code>lexicon</code>, <code>meta</code>, <code>metadata</code> and
|
|
<span><code>tag</code></span> declarations.</p>
|
|
<p>The following are examples of XML Form grammars headers each
|
|
including all declarations permitted on the <code>grammar</code>
|
|
element and one with the DOCTYPE declaration.</p>
|
|
<pre class="xml" xml:space="preserve">
|
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
|
|
|
<grammar version="1.0"
|
|
xml:lang="en"
|
|
mode="voice"
|
|
root="myRule"
|
|
xmlns="http://www.w3.org/2001/06/grammar"
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://www.w3.org/2001/06/grammar
|
|
http://www.w3.org/TR/speech-grammar/grammar.xsd"
|
|
xml:base="http://www.example.com/base-file-path">
|
|
</pre>
|
|
<pre class="xml" xml:space="preserve">
|
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
|
|
|
<!DOCTYPE grammar PUBLIC "-//W3C//DTD GRAMMAR 1.0//EN"
|
|
"http://www.w3.org/TR/speech-grammar/grammar.dtd">
|
|
|
|
<grammar version="1.0"
|
|
xml:lang="fr-CA"
|
|
mode="voice"
|
|
root="QuebecCities"
|
|
xmlns="http://www.w3.org/2001/06/grammar"
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://www.w3.org/2001/06/grammar
|
|
http://www.w3.org/TR/speech-grammar/grammar.xsd"
|
|
xml:base="http://www.example.com/another-base-file-path">
|
|
</pre></blockquote>
|
|
<h3 id="id-S4.2"><a id="S4.2" name="S4.2" shape="rect">4.2 ABNF
|
|
Self-Identifying Header</a></h3>
|
|
<p>The <em>ABNF self-identifying header</em> must be present in any
|
|
legal stand-alone ABNF Form grammar document.</p>
|
|
<p>The first character of an ABNF document must be the "#" symbol
|
|
(x23) unless preceded by an optional XML 1.0 <a href=
|
|
"http://www.w3.org/TR/2000/REC-xml-20001006#charencoding" shape=
|
|
"rect"><em>byte order mark</em></a> <a href="#ref-xml" shape=
|
|
"rect">[XML §4.3.3]</a>. The ABNF byte order mark follows the
|
|
XML definition and requirements. For example, documents encoded in
|
|
UTF-16 must begin with the byte order mark.</p>
|
|
<p>The optional byte order mark and required "#" symbol must be
|
|
followed immediately by the exact string "ABNF" (x41 x42 x4d x46)
|
|
or the appropriate equivalent for the document's encoding (e.g. for
|
|
UTF-16 little-endian: x23 x00 x41 x00 x42 x00 x4d x00 x46 x00). If
|
|
the byte order mark is absent on a grammar encoded in UTF-16 then
|
|
the grammar processor should perform <a href=
|
|
"http://www.w3.org/TR/2000/REC-xml-20001006#sec-guessing" shape=
|
|
"rect">auto-detection of character encoding</a> in a manner
|
|
analogous to auto-detection of character encoding in XML <a href=
|
|
"#ref-xml" shape="rect">[XML §F]</a>.</p>
|
|
<p>Next follows a single space character (x20) and the required
|
|
version number which is "<code>1.0</code>" for this specification
|
|
(x31 x2e x30).</p>
|
|
<p>Next follows an optional <a href="#S4.4" shape="rect">character
|
|
encoding</a>. Section 4.4 defines character encodings in more
|
|
detail. If present, there must be a single space character (x20)
|
|
between the version number and the character encoding.</p>
|
|
<p>The self-identifying header is finalized with a semicolon (x3b)
|
|
followed immediately by a newline. The semicolon must be the first
|
|
character following the version number or the character encoding if
|
|
is present.</p>
|
|
<p>For the remaining declarations of the ABNF header <a href=
|
|
"#term-whitespace" shape="rect">white space</a> is not
|
|
significant.</p>
|
|
<h3 id="id-S4.3"><a id="S4.3" name="S4.3" shape="rect">4.3 XML Form
|
|
Prolog and Root Element</a></h3>
|
|
<p>A legal stand-alone XML Form grammar document must have a legal
|
|
<a href="http://www.w3.org/TR/2000/REC-xml-20001006#sec-prolog-dtd"
|
|
shape="rect">XML Prolog</a> <a href="#ref-xml" shape="rect">[XML
|
|
§2.8]</a>.</p>
|
|
<p>The XML prolog in an XML Form grammar comprises the XML
|
|
declaration and an optional DOCTYPE declaration referencing the
|
|
grammar DTD. It is followed by the root <code>grammar</code>
|
|
element. The XML prolog may also contain XML comments, processor
|
|
instructions and other content permitted by XML in a prolog.</p>
|
|
<p>The version number of the XML declaration indicates which
|
|
version of XML is being used. The version number of the
|
|
<code>grammar</code> element indicates which version of the grammar
|
|
specification is being used — "<code>1.0</code>" for this
|
|
specification. The grammar version is a required attribute.</p>
|
|
<p>The grammar element must designate the grammar namespace. This
|
|
can be achieved by declaring an <code>xmlns</code> attribute or an
|
|
attribute with an "xmlns" prefix. See <a href="#ref-xmlns" shape=
|
|
"rect">[XMLNS]</a> for details. Note that when the xmlns attribute
|
|
is used alone, it sets the default namespace for the element on
|
|
which it appears and for any child elements. The namespace for XML
|
|
Form grammars is defined as <a href=
|
|
"http://www.w3.org/2001/06/grammar" shape=
|
|
"rect">http://www.w3.org/2001/06/grammar</a>.</p>
|
|
<p>It is recommended that the grammar element also indicate the
|
|
location of the grammar schema (see <a href="#AppC" shape=
|
|
"rect">Appendix C</a>) via the <code>xsi:schemaLocation</code>
|
|
attribute from <a href="#ref-schema1" shape="rect">[SCHEMA1]</a>.
|
|
Although such indication is not required, to encourage it this
|
|
document provides such indication on all of the examples:</p>
|
|
<pre class="xml" xml:space="preserve">
|
|
<grammar version="1.0"
|
|
xmlns="http://www.w3.org/2001/06/grammar"
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://www.w3.org/2001/06/grammar
|
|
http://www.w3.org/TR/speech-grammar/grammar.xsd">
|
|
...
|
|
</grammar>
|
|
</pre>
|
|
<p>If present, the optional DOCTYPE must reference the standard
|
|
DOCTYPE and identifier.</p>
|
|
<pre class="xml" xml:space="preserve">
|
|
<!DOCTYPE grammar PUBLIC "-//W3C//DTD GRAMMAR 1.0//EN"
|
|
"http://www.w3.org/TR/speech-grammar/grammar.dtd">
|
|
</pre>
|
|
<p>The character encoding is defined on the XML declaration as
|
|
defined by the XML specification. See <a href="#S4.4" shape=
|
|
"rect">Section 4.4</a> for detail.</p>
|
|
<p>The language is defined by the <code>xml:lang</code> attribute
|
|
on the <code>grammar</code> element. See <a href="#S4.5" shape=
|
|
"rect">Section 4.5</a> for details.</p>
|
|
<p>The grammar <code>mode</code> is defined on the
|
|
<code>grammar</code> element. See <a href="#S4.6" shape=
|
|
"rect">Section 4.6</a> for details.</p>
|
|
<p>The <code>root</code> rule is defined on the
|
|
<code>grammar</code> element. See <a href="#S4.7" shape=
|
|
"rect">Section 4.7</a> for details.</p>
|
|
<p>The <code>tag-format</code> is defined on the
|
|
<code>grammar</code> element. See <a href="#S4.8" shape=
|
|
"rect">Section 4.8</a> for details.</p>
|
|
<p>The base URI for the document is defined by the
|
|
<code>xml:base</code> attribute on the <code>grammar</code>
|
|
element. See <a href="#S4.9" shape="rect">Section 4.9</a> for
|
|
details.</p>
|
|
<h3 id="id-S4.4"><a id="S4.4" name="S4.4" shape="rect">4.4
|
|
Character Encoding</a></h3>
|
|
<p>The character encoding declaration indicates the scheme used for
|
|
encoding character data in the document. For example, for US
|
|
applications it would be common to use US-ASCII, UTF-8 (8-bit
|
|
Unicode) or ISO-8859-1. For Japanese grammars, character encodings
|
|
such as EUC-JP and UTF-16 (16-bit Unicode) could be used.</p>
|
|
<p>Except for the different syntactic representation, the ABNF Form
|
|
follows the character encoding handling defined for XML. XML
|
|
grammar processors must accept both the UTF-8 and UTF-16 encodings
|
|
of ISO/IEC 10646 and may support other character encodings. This
|
|
follows from an XML grammar processor being a compliant XML
|
|
processor and thus required to support those character encodings.
|
|
For consistency, ABNF grammar processor must also accept both the
|
|
UTF-8 and UTF-16 encodings of ISO/IEC 10646 and may support other
|
|
character encodings.</p>
|
|
<p>For both XML Form and ABNF Form grammars the declaration of the
|
|
character encoding is optional but strongly recommended. XML
|
|
defines behavior for XML processors that receive an XML document
|
|
without a character encoding declaration. For consistency an ABNF
|
|
grammar processor must follow the same behavior (with adjustments
|
|
for the different syntax). (Note the character encoding declaration
|
|
is optional only in cases where it is optional for a legal XML
|
|
document.)</p>
|
|
<blockquote>
|
|
<h4 id="id-S4.4-abnf">ABNF Form</h4>
|
|
<p>The character encoding declaration is part of the
|
|
self-identifying grammar header defined in <a href="#S4.1" shape=
|
|
"rect">Section 4.1</a> and is processed in combination with the
|
|
byte order mark, if present, using the same procedure as XML 1.0
|
|
<a href="#ref-xml" shape="rect">[XML §4.3.3]</a>.</p>
|
|
<p>The following are examples of ABNF self-identifying grammar
|
|
headers with and without the character encoding declaration.</p>
|
|
<p>Note: the ABNF Form syntax does not provide a character
|
|
reference syntax for entry of a specific character, for example,
|
|
one not directly accessible from available input devices. This
|
|
contrasts with <a href=
|
|
"http://www.w3.org/TR/2000/REC-xml-20001006#sec-references" shape=
|
|
"rect">XML 1.0 syntax for character references</a> <a href=
|
|
"#ref-xml" shape="rect">[XML §4.1]</a>. For development
|
|
requiring character references the XML Form of the specification is
|
|
recommended.</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
#ABNF 1.0 ISO-8859-1;
|
|
</pre>
|
|
<pre class="abnf" xml:space="preserve">
|
|
#ABNF 1.0 EUC-JP;
|
|
</pre>
|
|
<pre class="abnf" xml:space="preserve">
|
|
#ABNF 1.0;
|
|
</pre>
|
|
<h4 id="id-S4.4-xml">XML Form</h4>
|
|
<p>XML declares character encodings as part of the document's XML
|
|
declaration on the first line of the document.</p>
|
|
<p>The following are examples of XML headers with and without the
|
|
character encoding declaration.</p>
|
|
<pre class="xml" xml:space="preserve">
|
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
|
</pre>
|
|
<pre class="xml" xml:space="preserve">
|
|
<?xml version="1.0" encoding="EUC-JP"?>
|
|
</pre>
|
|
<pre class="xml" xml:space="preserve">
|
|
<?xml version="1.0"?>
|
|
</pre></blockquote>
|
|
<h3 id="id-S4.5"><a id="S4.5" name="S4.5" shape="rect">4.5
|
|
Language</a></h3>
|
|
<p>The language declaration of a grammar provides the <a href=
|
|
"#term-language" shape="rect">language identifier</a> that
|
|
indicates the primary language contained by the document and
|
|
optionally indicates a country or other variation. Additionally,
|
|
any legal rule expansion may be <a href="#S2.7" shape=
|
|
"rect">labeled with a language identifier</a>.</p>
|
|
<p>The language declaration is required for all speech recognition
|
|
grammars: i.e. all grammars for which the <a href="#S4.6" shape=
|
|
"rect"><code>mode</code></a> is "voice". (Note that mode defaults
|
|
to voice if there is no explicit mode declaration in ABNF or
|
|
<code>mode</code> attribute in XML.)</p>
|
|
<p>If an XML Form grammar is incorporated within another XML
|
|
document — for example, as supported by VoiceXML 2.0 — then the
|
|
<code>xml:lang</code> attribute is optional on the
|
|
<code>grammar</code> element and the <code>xml:lang</code>
|
|
attribute must be inherited from the enclosing document.</p>
|
|
<p>In <a href="#AppE" shape="rect">DTMF grammars</a> a language
|
|
declaration must be ignored if present.</p>
|
|
<p>The conformance definition in <a href="#S5" shape="rect">Section
|
|
5</a> defines the behavior of a grammar processor when it
|
|
encounters a language variant that it does not support.</p>
|
|
<blockquote>
|
|
<h4 id="id-S4.5-abnf">ABNF Form</h4>
|
|
<p><span>The ABNF header must contain zero or one language
|
|
declaration.</span> It consists of the keyword
|
|
"<code>language</code>", <a href="#term-whitespace" shape=
|
|
"rect">white space</a>, a legal <a href="#term-language" shape=
|
|
"rect">language identifier</a>, optional <a href="#term-whitespace"
|
|
shape="rect">white space</a> and a terminating semicolon character
|
|
(';').</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
language en-US;
|
|
</pre>
|
|
<pre class="abnf" xml:space="preserve">
|
|
language fr;
|
|
</pre>
|
|
<h4 id="id-S4.5-xml">XML Form</h4>
|
|
<p>Following the XML 1.0 specification <a href="#ref-xml" shape=
|
|
"rect">[XML §2.12]</a> the <a href="#term-language" shape=
|
|
"rect">language identifier</a> is indicated by an
|
|
<code>xml:lang</code> attribute on the root <code>grammar</code>
|
|
element.</p>
|
|
<pre class="xml" xml:space="preserve">
|
|
<grammar xmlns="http://www.w3.org/2001/06/grammar"
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://www.w3.org/2001/06/grammar
|
|
http://www.w3.org/TR/speech-grammar/grammar.xsd"
|
|
xml:lang="en-US"
|
|
version="1.0">
|
|
</pre>
|
|
<pre class="xml" xml:space="preserve">
|
|
<grammar xmlns="http://www.w3.org/2001/06/grammar"
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://www.w3.org/2001/06/grammar
|
|
http://www.w3.org/TR/speech-grammar/grammar.xsd"
|
|
xml:lang="fr"
|
|
version="1.0">
|
|
</pre></blockquote>
|
|
<h3 id="id-S4.6"><a id="S4.6" name="S4.6" shape="rect">4.6 Grammar
|
|
Mode</a></h3>
|
|
<p>The mode of a grammar indicates the type of input that the user
|
|
agent should be detecting. The default mode is "<code>voice</code>"
|
|
for speech recognition grammars. An alternative input mode defined
|
|
in <a href="#AppE" shape="rect">Appendix E</a> is
|
|
"<code>dtmf</code>" input.</p>
|
|
<p>The <code>mode</code> attribute indicates how to interpret the
|
|
<a href="#S2.1" shape="rect">tokens</a> contained by the grammar.
|
|
Speech tokens are expected to be detected as speech audio that
|
|
sounds like the token. Behavior with DTMF input, if supported, is
|
|
defined in <a href="#AppE" shape="rect">Appendix E</a>.</p>
|
|
<p>It is often the case that a different user agent is used for
|
|
detecting DTMF tones than for speech recognition. The same may be
|
|
true for other modes defined in future revisions of the
|
|
specification.</p>
|
|
<p>The specification does not define a mechanism by which a single
|
|
grammar can mix modes: that is, a representation for a mixed
|
|
"<code>voice</code>" and "<code>dtmf</code>" grammar is not
|
|
defined. Moreover, it is illegal for a rule reference in one
|
|
grammar to reference any grammar with a different mode.</p>
|
|
<p>A user agent may, however, support the simultaneous activation
|
|
of more than one grammar including both "<code>voice</code>" and
|
|
"<code>dtmf</code>" grammars. This is necessary, for example, for
|
|
DTMF-enabled VoiceXML browsers <a href="#ref-vxml2" shape=
|
|
"rect">[VXML2]</a>. (Note: parallel activation implies disjunction
|
|
at the root level of the grammars rather than mixing of modes
|
|
within the structure of the grammars.)</p>
|
|
<blockquote>
|
|
<h4 id="id-S4.6-abnf">ABNF Form</h4>
|
|
<p><span>The ABNF header must contain zero or one mode
|
|
declaration.</span> It consists of the keyword "<code>mode</code>",
|
|
<a href="#term-whitespace" shape="rect">white space</a>, either
|
|
"<code>voice</code>" or "<code>dtmf</code>" optional <a href=
|
|
"#term-whitespace" shape="rect">white space</a> and a terminating
|
|
semicolon character (';'). If the ABNF header does not declare the
|
|
mode then it defaults to <code>voice</code>.</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
mode voice;
|
|
</pre>
|
|
<pre class="abnf" xml:space="preserve">
|
|
mode dtmf;
|
|
</pre>
|
|
<h4 id="id-S4.6-xml">XML Form</h4>
|
|
<p>The <code>mode</code> declaration is provided as an optional
|
|
<code>mode</code> attribute on the root <code>grammar</code>
|
|
element. Legal values are <code>"voice"</code> and
|
|
<code>"dtmf"</code>. If the mode attribute is omitted then the
|
|
value defaults to <code>voice</code>.</p>
|
|
<pre class="xml" xml:space="preserve">
|
|
<grammar mode="voice"
|
|
version="1.0"
|
|
xml:lang="en-US"
|
|
xmlns="http://www.w3.org/2001/06/grammar"
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://www.w3.org/2001/06/grammar
|
|
http://www.w3.org/TR/speech-grammar/grammar.xsd">
|
|
</pre>
|
|
<pre class="xml" xml:space="preserve">
|
|
<grammar mode="dtmf"
|
|
version="1.0"
|
|
xmlns="http://www.w3.org/2001/06/grammar"
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://www.w3.org/2001/06/grammar
|
|
http://www.w3.org/TR/speech-grammar/grammar.xsd">
|
|
</pre></blockquote>
|
|
<h3 id="id-S4.7"><a id="S4.7" name="S4.7" shape="rect">4.7 Root
|
|
Rule</a></h3>
|
|
<p>Both the XML Form and ABNF Form permit the grammar header to
|
|
optionally declare a single rule to be the root rule of the
|
|
grammar. The rule declared as the root rule must be defined within
|
|
the scope of the grammar. The rule declared as the root rule may be
|
|
<a href="#S3.2" shape="rect">scoped</a> as either
|
|
<code>public</code> or <code>private</code>.</p>
|
|
<p>A<span>n</span> <a href="#S2.2" shape=
|
|
"rect"><span>implicit</span> rule reference</a> to the root rule of
|
|
a grammar is legal. The syntax for <span>implicitly</span>
|
|
referencing root rules is defined in <a href="#S2.2" shape=
|
|
"rect">Section 2.2</a>. It is an error to reference a grammar
|
|
<span>implicitly</span> by its root if that grammar does not
|
|
declare a legal root rule.</p>
|
|
<p>Although a grammar is not required to declare a root rule it is
|
|
good practice to declare the root rule of any grammar.</p>
|
|
<blockquote>
|
|
<h4 id="id-S4.7-abnf">ABNF Form</h4>
|
|
<p><span>The ABNF header must contain zero or one root rule
|
|
declaration.</span> It consists of the keyword "<code>root</code>",
|
|
<a href="#term-whitespace" shape="rect">white space</a>, the
|
|
<a href="#S3.1" shape="rect">legal rulename</a> of a rule defined
|
|
within the grammar prefixed by the dollar sign ('$'), optional
|
|
<a href="#term-whitespace" shape="rect">white space</a> and a
|
|
terminating semicolon character (';'). If the ABNF header does not
|
|
declare the root rule then it is not legal to
|
|
<span>implicitly</span> reference the grammar by its root.</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
root $rulename;
|
|
</pre>
|
|
<h4 id="id-S4.7-xml">XML Form</h4>
|
|
<p>The <code>root</code> rulename declaration is provided as an
|
|
optional <code>root</code> attribute on the <code>grammar</code>
|
|
element. The <code>root</code> declaration must identify one rule
|
|
defined elsewhere within the same grammar. The value of the root
|
|
attribute is an XML IDREF (not a URI) and must not include the
|
|
number sign ('#').</p>
|
|
<pre class="xml" xml:space="preserve">
|
|
<grammar root="rulename" ...>
|
|
</pre></blockquote>
|
|
<h3 id="id-S4.8"><a id="S4.8" name="S4.8" shape="rect">4.8 Tag
|
|
Format</a></h3>
|
|
<p>The <code>tag-format</code> declaration is an optional
|
|
declaration of a <em>tag-format identifier</em> that indicates the
|
|
content type of all <span><a href="#S2.6" shape="rect">rule
|
|
tags</a> and <a href="#S4.12" shape="rect">header tags</a></span>
|
|
contained within a grammar.</p>
|
|
<p>The tag-format identifier is a <a href="#term-uri" shape=
|
|
"rect">URI</a>. It is recommended that the tag format identifier
|
|
indicate both the content type and a version. Tags typically
|
|
contain content for a <a href="#S1.4" shape="rect">semantic
|
|
interpretation</a> processor and in such cases the identifier, if
|
|
present, should indicate the semantic processor to use.</p>
|
|
<p>Tag-format identifier values beginning with the string
|
|
"semantics/x.y" (where x and y are digits) are reserved for use by
|
|
the <i>W3C Semantic Interpretation for Speech Recognition</i>
|
|
specification <a href="#ref-sem" shape="rect">[SEM]</a> or future
|
|
versions of the specification.</p>
|
|
<p>Grammar processor handling of tags is undefined if the tag
|
|
format declaration is omitted.</p>
|
|
<blockquote>
|
|
<h4 id="id-S4.8-abnf">ABNF Form</h4>
|
|
<p><span>The ABNF header must contain zero or one tag format
|
|
declaration.</span> It consists of the keyword
|
|
"<code>tag-format</code>", <a href="#term-whitespace" shape=
|
|
"rect">white space</a>, a tag format identifier (an ABNF <a href=
|
|
"#term-uri" shape="rect">URI</a>), optional <a href=
|
|
"#term-whitespace" shape="rect">white space</a> and a terminating
|
|
semicolon character (';').</p>
|
|
<p>Informative example ("semantics/1.0" is <span>a reserved
|
|
identifier)</span> :</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
tag-format <semantics/1.0>;
|
|
</pre>
|
|
<h4 id="id-S4.8-xml">XML Form</h4>
|
|
<p>The <code>tag-format</code> is an optional attribute of the
|
|
<code>grammar</code> element and contains a tag format
|
|
identifier.</p>
|
|
<pre class="xml" xml:space="preserve">
|
|
<grammar tag-format="semantics/1.0" ...>
|
|
</pre></blockquote>
|
|
<h3 id="id-S4.9"><a id="S4.9" name="S4.9" shape="rect">4.9 Base
|
|
URI</a></h3>
|
|
<p>Relative URIs are resolved according to a <em>base URI</em>,
|
|
which may come from a variety of sources. The base URI declaration
|
|
allows authors to specify a document's base URI explicitly. See
|
|
<a href="#S4.9.1" shape="rect">Section 4.9.1</a> for details on the
|
|
resolution of relative URIs.</p>
|
|
<p>The path information specified by the base URI declaration only
|
|
affects URIs in the document where the element appears.</p>
|
|
<p>The base URI declaration is permitted but optional in both the
|
|
XML Form and the ABNF Form.</p>
|
|
<p>Note: the base URI may be declared in a <a href="#S4.11.1"
|
|
shape="rect">meta declaration</a> but the explicit base declaration
|
|
is recommended for both the ABNF Form and XML Form.</p>
|
|
<blockquote>
|
|
<h4 id="id-S4.9-abnf">ABNF Form</h4>
|
|
<p><span>The ABNF header must contain zero or one base URI
|
|
declaration.</span> It consists of the keyword "<code>base</code>",
|
|
<a href="#term-whitespace" shape="rect">white space</a>, a legal
|
|
<a href="#term-uri" shape="rect">ABNF URI</a>, optional <a href=
|
|
"#term-whitespace" shape="rect">white space</a> and a terminating
|
|
semicolon character (';').</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
base <http://www.example.com/base-file-path>;
|
|
</pre>
|
|
<pre class="abnf" xml:space="preserve">
|
|
base <http://www.example.com/another-base-file-path>;
|
|
</pre>
|
|
<h4 id="id-S4.9-xml">XML Form</h4>
|
|
<p>The base URI declaration follows <a href="#ref-xml-base" shape=
|
|
"rect">[XML-BASE]</a> and is indicated by a <code>xml:base</code>
|
|
attribute on the root <code>grammar</code> element.</p>
|
|
<pre class="xml" xml:space="preserve">
|
|
<grammar xmlns="http://www.w3.org/2001/06/grammar"
|
|
xml:base="http://www.example.com/base-file-path"
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://www.w3.org/2001/06/grammar
|
|
http://www.w3.org/TR/speech-grammar/grammar.xsd"
|
|
version="1.0">
|
|
</pre>
|
|
<pre class="xml" xml:space="preserve">
|
|
<grammar xmlns="http://www.w3.org/2001/06/grammar"
|
|
xml:base="http://www.example.com/another-base-file-path"
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://www.w3.org/2001/06/grammar
|
|
http://www.w3.org/TR/speech-grammar/grammar.xsd"
|
|
version="1.0">
|
|
</pre></blockquote>
|
|
<h4 id="id-S4.9.1-abnf"><a id="S4.9.1" name="S4.9.1" shape=
|
|
"rect">4.9.1 Resolving Relative URIs</a></h4>
|
|
<p>User agents must calculate the base URI for resolving relative
|
|
URIs according to <a href="#ref-rfc2396" shape=
|
|
"rect">[RFC2396]</a>. The following describes how RFC 2396 applies
|
|
to grammar documents.</p>
|
|
<p>User agents must calculate the base URI according to the
|
|
following precedences (highest priority to lowest):</p>
|
|
<ol>
|
|
<li>The base URI is set by the <code>xml:base</code> attribute on
|
|
the <code>grammar</code> element or the <code>base</code>
|
|
declaration in the ABNF header (see Section 4.9).</li>
|
|
<li>The base URI is provided in a <a href="#S4.11.1" shape=
|
|
"rect">meta declaration</a>.</li>
|
|
<li>The base URI is given by metadata discovered during a protocol
|
|
interaction, such as an HTTP header (see <a href="#ref-rfc2616"
|
|
shape="rect">[RFC2616]</a>).</li>
|
|
<li>By default, the base URI is that of the current document. Not
|
|
all grammar documents have a base URI (e.g., a valid grammar
|
|
document may appear in an email and may not be designated by a
|
|
URI). Such grammar documents are not valid if they contain relative
|
|
URIs and rely on a default base URI.</li>
|
|
</ol>
|
|
<h3 id="id-S4.10"><a id="S4.10" name="S4.10" shape="rect"></a>4.10
|
|
Pronunciation Lexicon</h3>
|
|
<p>A grammar may optionally reference one or more external
|
|
pronunciation lexicon documents. A lexicon document is identified
|
|
by a <a href="#term-uri" shape="rect">URI</a> with an optional
|
|
<a href="#term-media-type" shape="rect">media type</a>.</p>
|
|
<p>The pronunciation information contained within a lexicon
|
|
document is used only for tokens defined within the enclosing
|
|
grammar.</p>
|
|
<p>The W3C Voice Browser Working Group is developing the
|
|
Pronunciation Lexicon Markup Language <a href="#ref-lex" shape=
|
|
"rect">[LEX]</a>. The specification will address the matching
|
|
process between tokens and lexicon entries and the mechanism by
|
|
which a speech recognizer handles multiple pronunciations from
|
|
internal and grammar-specified lexicons. Pronunciation handling
|
|
with proprietary lexicon formats will necessarily be specific to
|
|
the speech recognizer.</p>
|
|
<p>Pronunciation lexicons are necessarily language-specific.
|
|
Pronunciation lookup in a lexicon and pronunciation inference for
|
|
any token may use an algorithm that is language-specific. (See
|
|
<a href="#S2.1" shape="rect">Section 2.1</a> for additional
|
|
information on token handling and pronunciations.)</p>
|
|
<blockquote>
|
|
<h4 id="id-S4.10-abnf">ABNF Form</h4>
|
|
<p>The ABNF header may contain any number of pronunciation lexicon
|
|
declarations (zero, one or many). The lexicon declaration consists
|
|
of the "<code>lexicon</code>" keyword followed by <a href=
|
|
"#term-whitespace" shape="rect">white space</a>, an <a href=
|
|
"#term-uri" shape="rect">ABNF URI</a> or <a href="#term-media-type"
|
|
shape="rect">ABNF URI with media type</a>, optional white space and
|
|
a closing semicolon (';'). (Note that a lexicon URI is not preceded
|
|
by a dollar sign as is the case for ABNF rule references.)
|
|
Example:</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
#ABNF V1.0 ISO-8859-1;
|
|
language en-US;
|
|
|
|
lexicon <http://www.example.com/lexicon.file>;
|
|
lexicon <http://www.example.com/strange-city-names.file>~<media-type>;
|
|
...
|
|
</pre>
|
|
<h4 id="id-S4.10-xml">XML Form</h4>
|
|
<p>Any number of <code>lexicon</code> elements may occur as
|
|
immediate children of the <code>grammar</code> element. The
|
|
<code>lexicon</code> element must have a <code>uri</code> attribute
|
|
specifying a <a href="#term-uri" shape="rect">URI</a> that
|
|
identifies the location of the pronunciation lexicon document.</p>
|
|
<p>The <code>lexicon</code> element may have a <code>type</code>
|
|
attribute that specifies the <a href="#term-media-type" shape=
|
|
"rect">media type</a> of the pronunciation lexicon document.</p>
|
|
<pre class="xml" xml:space="preserve">
|
|
<grammar xmlns="http://www.w3.org/2001/06/grammar"
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://www.w3.org/2001/06/grammar
|
|
http://www.w3.org/TR/speech-grammar/grammar.xsd"
|
|
xml:lang="en" version="1.0">
|
|
|
|
<lexicon uri="http://www.example.com/lexicon.file"/>
|
|
<lexicon uri="http://www.example.com/strange-city-names.file" type="media-type"/>
|
|
...
|
|
</pre></blockquote>
|
|
<h3 id="id-S4.11"><a id="S4.11" name="S4.11" shape="rect">4.11 Meta
|
|
Data</a></h3>
|
|
<p>Grammar documents let authors specify metadata — information
|
|
about a document rather than document content — in a number of
|
|
ways.</p>
|
|
<p>A <a href="#S4.11.1" shape="rect"><code>meta</code>
|
|
declaration</a> in either the ABNF Form or XML Form may be used to
|
|
express metadata information in both XML Form and ABNF Form
|
|
grammars or to reference metadata available in an external
|
|
resource. The XML Form also supports a <a href="#S4.11.2" shape=
|
|
"rect"><code>metadata</code> element</a> that provides a more
|
|
general and powerful treatment of metadata information than
|
|
<code>meta</code>. Since <code>metadata</code> requires an XML
|
|
metadata schema which cannot be expressed in ABNF, there is no
|
|
equivalent of <code>metadata</code> in the ABNF Form of
|
|
grammars.</p>
|
|
<h4 id="id-S4.11.1"><a id="S4.11.1" name="S4.11.1" shape=
|
|
"rect">4.11.1 Meta and HTTP-Equiv</a></h4>
|
|
<p>A <code>meta</code> declaration in either ABNF Form or the XML
|
|
Form associates a string to declared meta property or declares
|
|
"http-equiv" content.</p>
|
|
<p>The <code>seeAlso</code> property is the only defined meta
|
|
property name. It is used to specify a resource that might provide
|
|
additional metadata information about the containing grammar. This
|
|
property is modelled on the <a href=
|
|
"http://www.w3.org/TR/2000/CR-rdf-schema-20000327/#s2.3.4" shape=
|
|
"rect"><code>rdfs:seeAlso</code> property</a> of Resource
|
|
Description Framework (RDF) Schema Specification 1.0 <a href=
|
|
"#ref-rdf-schema" shape="rect">[RDF-SCHEMA §2.3.4]</a>.</p>
|
|
<p>It is recommended that for general metadata properties that
|
|
grammar authors follow the metadata properties defined in the
|
|
Dublin Core Metadata Initiative <a href="#ref-dc" shape=
|
|
"rect">[DC]</a>. For example, "Creator" to identify the entity
|
|
primarily responsible for making the content of the grammar, "Date"
|
|
to indicate creation date, or "Source" to indicate the resource
|
|
From which a grammar is derived (e.g. when converting an XML Form
|
|
grammar to the ABNF Form, use "Source" to provide the URI for the
|
|
original document.)</p>
|
|
<blockquote>
|
|
<h4 id="id-S4.11.1-abnf">ABNF Form</h4>
|
|
<p>The ABNF header may contain any number of meta declarations and
|
|
http-equiv declarations (zero, one or many). Each declaration
|
|
consists of the "<code>meta</code>" or "<code>http-equiv</code>"
|
|
keyword followed by <a href="#term-whitespace" shape="rect">white
|
|
space</a>, the name string delimited by quotes, the keyword
|
|
"<code>is</code>", <a href="#term-whitespace" shape="rect">white
|
|
space</a>, the content string delimited by quotes, optional white
|
|
space and a closing semicolon (';').</p>
|
|
<p>The name string and the content string must be delimited by
|
|
either a matching pair of double quotes ('"') or a matching pair of
|
|
single quotes ("'").</p>
|
|
<p>Informative example:</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
#ABNF 1.0;
|
|
|
|
meta "Creator" is "Stephanie Williams";
|
|
meta "seeAlso" is "http://example.com/my-grammar-metadata.xml";
|
|
|
|
http-equiv "Expires" is '0';
|
|
http-equiv "Date" is "Thu, 12 Dec 2000 23:27:21 GMT";
|
|
</pre>
|
|
<h4 id="id-S4.11.1-xml">XML Form</h4>
|
|
<p>A metadata property is declared with a <code>meta</code>
|
|
element. Either a <code>name</code> or <code>http-equiv</code>
|
|
attribute is required. It is illegal to provide both
|
|
<code>name</code> and <code>http-equiv</code> attributes. A
|
|
<code>content</code> attribute is required. The <code>meta</code>,
|
|
<code>metadata</code> and <code>lexicon</code> elements must occur
|
|
before all rule elements contained with the root
|
|
<code>grammar</code> element. There are no constraints on the
|
|
ordering of the <code>meta</code>, <code>metadata</code> and
|
|
<code>lexicon</code> elements.</p>
|
|
<p>Informative example:</p>
|
|
<pre class="xml" xml:space="preserve">
|
|
<?xml version="1.0"?>
|
|
<grammar version="1.0" xml:lang="en-US"
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://www.w3.org/2001/06/grammar
|
|
http://www.w3.org/TR/speech-grammar/grammar.xsd"
|
|
xmlns="http://www.w3.org/2001/06/grammar">
|
|
|
|
<meta name="Creator" content="Stephanie Williams"/>
|
|
<meta name="seeAlso" content="http://example.com/my-grammar-metadata.xml"/>
|
|
|
|
<meta http-equiv="Expires" content="0"/>
|
|
<meta http-equiv="Date" content="Thu, 12 Dec 2000 23:27:21 GMT"/>
|
|
...
|
|
</grammar>
|
|
</pre></blockquote>
|
|
<h4 id="id-S4.11.2"><a id="S4.11.2" name="S4.11.2" shape=
|
|
"rect">4.11.2 XML Metadata (XML Only)</a></h4>
|
|
<p>The <code>metadata</code> element is container in which
|
|
information about the document can be placed using a metadata
|
|
schema. Although any metadata schema can be used with
|
|
<code>metadata</code>, it is recommended that the Resource
|
|
Description Format (RDF) schema <a href="#ref-rdf-schema" shape=
|
|
"rect">[RDF-SCHEMA]</a> is used in conjunction with the general
|
|
metadata properties defined in the Dublin Core Metadata Initiative
|
|
<a href="#ref-dc" shape="rect">[DC]</a>.</p>
|
|
<p>RDF is a declarative language and provides a standard way for
|
|
using XML to represent metadata in the form of statements about
|
|
properties and relationships of items on the Web. Content creators
|
|
should refer to W3C metadata Recommendations <a href=
|
|
"#ref-rdf-syntax" shape="rect">[RDF-SYNTAX]</a> and <a href=
|
|
"#ref-rdf-schema" shape="rect">[RDF-SCHEMA]</a> when deciding which
|
|
metadata RDF schema to use in their documents. Content creators
|
|
should also refer to the Dublin Core Metadata Initiative <a href=
|
|
"#ref-dc" shape="rect">[DC]</a>, which is a set of generally
|
|
applicable core metadata properties (e.g., Title, Creator, Subject,
|
|
Description, Copyrights, etc.).</p>
|
|
<p>This specification only defines an XML representation for this
|
|
form of metadata declaration. There is no ABNF equivalent for
|
|
<code>metadata</code>. A conversion of an XML Form grammar to the
|
|
ABNF Form may extract the XML metadata into a separate document
|
|
that is referenced with a "seeAlso" meta declaration in the ABNF
|
|
document. Note: an agent that searches XML documents for metadata
|
|
represented with RDF would be unable to locate RDF even if it were
|
|
represented in ABNF. Thus, support for RDF in ABNF was considered
|
|
low utility.</p>
|
|
<blockquote>
|
|
<h4 id="id-S4.11.2-xml">XML Form</h4>
|
|
<p>Document properties declared with <code>metadata</code> element
|
|
can use any metadata schema. The <code>metadata</code>,
|
|
<code>meta</code>, and <code>lexicon</code> elements must occur
|
|
before all rule elements contained with the root
|
|
<code>grammar</code> element. There are no constraints on the
|
|
ordering of the <code>metadata</code>, <code>meta</code> and
|
|
<code>lexicon</code> elements.</p>
|
|
<p>Informative: This is an example of how <code>metadata</code> can
|
|
be included in an XML grammar document using the Dublin Core
|
|
version 1.0 RDF schema <a href="#ref-dc" shape="rect">[DC]</a>
|
|
describing general document information such as title, description,
|
|
date, and so on:</p>
|
|
<pre class="xml" xml:space="preserve">
|
|
<?xml version="1.0"?>
|
|
<grammar
|
|
xmlns="http://www.w3.org/2001/06/grammar" version="1.0"
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://www.w3.org/2001/06/grammar
|
|
http://www.w3.org/TR/speech-grammar/grammar.xsd"
|
|
xml:lang="en-US">
|
|
|
|
<metadata>
|
|
<rdf:RDF
|
|
xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
|
xmlns:rdfs = "http://www.w3.org/TR/1999/PR-rdf-schema-19990303#"
|
|
xmlns:dc = "http://purl.org/metadata/dublin_core#">
|
|
|
|
<!-- Metadata about the grammar document -->
|
|
<rdf:Description about="http://www.example.com/meta.grxml"
|
|
dc:Title="Digit Grammar"
|
|
dc:Description="Digit Grammar in W3C XML Form"
|
|
dc:Publisher="W3C"
|
|
dc:Language="en"
|
|
dc:Date="2002-02-14"
|
|
dc:Rights="Copyright 2002 Jan Smith"
|
|
dc:Format="application/srgs+xml" >
|
|
<dc:Creator>
|
|
<rdf:Seq ID="CreatorsAlphabeticalBySurname">
|
|
<rdf:li>Jackie Crystal</rdf:li>
|
|
<rdf:li>Jan Smith</rdf:li>
|
|
</rdf:Seq>
|
|
</dc:Creator>
|
|
</rdf:Description>
|
|
</rdf:RDF>
|
|
</metadata>
|
|
|
|
</grammar>
|
|
</pre></blockquote>
|
|
<h3 id="id-S4.12"><a id="S4.12" name="S4.12" shape=
|
|
"rect"><span>4.12 Tag</span></a></h3>
|
|
<p>A grammar may optionally specify one or more <code>tag</code>
|
|
declarations in the header. The content of a <code>tag</code> in
|
|
the header, just like a <a href="#S2.6" shape="rect">tag in rule
|
|
expansions</a>, is an arbitrary string which may be used for
|
|
<a href="#S1.4" shape="rect">semantic interpretation</a>.</p>
|
|
<blockquote>
|
|
<h4 id="id-S4.12-abnf"><span>ABNF Form</span></h4>
|
|
<p>The ABNF header may contain any number of tag declarations
|
|
(zero, one or many).</p>
|
|
<p>The tag declaration consists a string delimited as described in
|
|
<a href="#id-S2.6-abnf" shape="rect">S2.6 ABNF Form</a>, followed
|
|
by a closing semicolon (';').</p>
|
|
<p>The tag content is all text between the opening and closing
|
|
delimiters including leading and trailing <a href=
|
|
"#term-whitespace" shape="rect">whitespace</a>. The contents of the
|
|
tag are not parsed by the grammar processor.</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
#ABNF V1.0 ISO-8859-1;
|
|
language en-US;
|
|
{<a href="#S1.4" shape="rect">TAG-CONTENT-1</a>};
|
|
{!{<a href="#S1.4" shape="rect">TAG-CONTENT-2</a>}!};
|
|
|
|
$rule = . . .;
|
|
...
|
|
</pre>
|
|
<h4 id="id-S4.12-xml"><span>XML Form</span></h4>
|
|
<p>Any number of <code>tag</code> elements may occur as immediate
|
|
children of the <code>grammar</code> element. The content of
|
|
<code>tag</code> is CDATA.</p>
|
|
<pre class="xml" xml:space="preserve">
|
|
<grammar xmlns="http://www.w3.org/2001/06/grammar"
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://www.w3.org/2001/06/grammar
|
|
http://www.w3.org/TR/speech-grammar/grammar.xsd"
|
|
xml:lang="en" version="1.0">
|
|
|
|
<tag><a href="#S1.4" shape=
|
|
"rect">TAG-CONTENT-1</a><tag>
|
|
<tag><a href="#S1.4" shape=
|
|
"rect">TAG-CONTENT-2</a><tag>
|
|
|
|
...
|
|
</pre></blockquote>
|
|
<h3 id="id-S4.13"><a id="S4.13" name="S4.13" shape=
|
|
"rect"><span>4.13</span> Comments</a></h3>
|
|
<p>Comments may be placed in most places in a grammar document. For
|
|
XML, use XML comments. For ABNF there are documentation comments
|
|
and C/C++/Java-style comments.</p>
|
|
<blockquote>
|
|
<h4 id="id-S4.13-abnf">ABNF Form</h4>
|
|
<p>C/C++/Java comments are permitted. Documentation comments are
|
|
permitted before <code>grammar</code> and <code>language</code>
|
|
declarations and before any <code>rule</code> definition.</p>
|
|
<p><a href="#S3.3" shape="rect">Section 3.3</a> defines the format
|
|
for representing examples in documentation comments before a rule
|
|
definition.</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
// C++/Java-style single-line comment
|
|
/* C/C++/Java-style comment */
|
|
/** Java-style documentation comment */
|
|
</pre>
|
|
<h4 id="id-S4.13-xml">XML Form</h4>
|
|
<p>An XML comment has the following syntax.</p>
|
|
<pre class="xml" xml:space="preserve">
|
|
<!-- comment -->
|
|
</pre></blockquote>
|
|
<h3 id="id-S4.14"><a id="S4.14" name="S4.14" shape=
|
|
"rect"><span>4.14</span> Grammar Fetching</a></h3>
|
|
<p>The fetching and caching behavior of both ABNF Form and XML Form
|
|
grammar documents is defined primarily by the environment in which
|
|
the grammar processor operates. For instance, VoiceXML 1.0 and
|
|
VoiceXML 2.0 define certain fetching and caching behaviors that
|
|
apply to grammars activated by a VoiceXML browser. Similarly, any
|
|
API for a recognizer that supports ABNF Form or XML Form grammars
|
|
may apply fetching and caching behaviors.</p>
|
|
<p>Grammar processors are recommended to support the following
|
|
interpretation of "rendering" a grammar for the purpose of
|
|
determining document freshness.</p>
|
|
<p><em>Activation</em> of a grammar is the point at which the
|
|
recognizer begins detection of user input matching the grammar and
|
|
is therefore analogous to the action of visual or audio rendering
|
|
of system output. As with output rendering, grammar freshness
|
|
should be checked close to the moment of grammar activation.</p>
|
|
<h3 id="id-S4.15"><a id="S4.15" name="S4.15" shape=
|
|
"rect"><span>4.15</span> ABNF Keywords</a></h3>
|
|
<p>ABNF keywords are case sensitive. The keywords of the ABNF
|
|
language are not reserved. The keywords with specified meaning in
|
|
ABNF are:</p>
|
|
<table border="1" cellpadding="3" summary="ABNF Keywords">
|
|
<tr>
|
|
<th colspan="1" rowspan="1">Context</th>
|
|
<th colspan="1" rowspan="1">Keywords</th>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1">Language declaration</td>
|
|
<td colspan="1" rowspan="1">"language"</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1">Mode declaration</td>
|
|
<td colspan="1" rowspan="1">"mode"</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1">Root declaration</td>
|
|
<td colspan="1" rowspan="1">"root"</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1">Tag format declaration</td>
|
|
<td colspan="1" rowspan="1">"tag-format"</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1">Base URI declaration</td>
|
|
<td colspan="1" rowspan="1">"base"</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1">Pronunciation lexicon</td>
|
|
<td colspan="1" rowspan="1">"lexicon"</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1">Meta or HTTP-equiv declaration</td>
|
|
<td colspan="1" rowspan="1">"meta", "http-equiv", "is"</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1">Rule definition</td>
|
|
<td colspan="1" rowspan="1">"public", "private"</td>
|
|
</tr>
|
|
</table>
|
|
<p>Since keywords are not reserved they may be used as rulenames
|
|
and as tokens. The following is a legal grammar that accepts as
|
|
input a sequence of one or more "public" tokens.</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
#ABNF 1.0 ISO-8859-1;
|
|
|
|
language en-AU;
|
|
root $public;
|
|
mode voice;
|
|
|
|
public $public = public $public | public;
|
|
</pre>
|
|
<h2 id="id-S5"><a id="S5" name="S5" shape="rect">5.
|
|
Conformance</a></h2>
|
|
<p><strong>This section is normative.</strong></p>
|
|
<p>Different sets of grammar conformance criteria exist for:</p>
|
|
<ul>
|
|
<li class="tocline">5.1 <a href="#S5.1" shape="rect">Conforming XML
|
|
Form Grammar Fragments</a></li>
|
|
<li class="tocline">5.2 <a href="#S5.2" shape="rect">Conforming
|
|
Stand-Alone XML Form Grammar Document</a></li>
|
|
<li class="tocline">5.3 <a href="#S5.3" shape="rect">Using XML Form
|
|
Grammars with other Namespaces</a></li>
|
|
<li class="tocline">5.4 <a href="#S5.4" shape="rect">Conforming XML
|
|
Form Grammar Processors</a></li>
|
|
<li class="tocline">5.5 <a href="#S5.5" shape="rect">Conforming
|
|
Stand-Alone ABNF Form Grammar Documents</a></li>
|
|
<li class="tocline">5.6 <a href="#S5.6" shape="rect">Conforming
|
|
ABNF Form Grammar Processors</a></li>
|
|
<li class="tocline">5.7 <a href="#S5.7" shape="rect">Conforming
|
|
ABNF/XML Form Grammar Processors</a></li>
|
|
<li class="tocline">5.8 <a href="#S5.8" shape="rect">Conforming
|
|
User Agents</a></li>
|
|
</ul>
|
|
<h3 id="id-S5.1"><a id="S5.1" name="S5.1" shape="rect">5.1:
|
|
Conforming XML Form Grammar Fragments</a></h3>
|
|
<p>An XML Form grammar document fragment is a <em>Conforming XML
|
|
Form Grammar Fragment</em> if:</p>
|
|
<ul>
|
|
<li>it is a <a href=
|
|
"http://www.w3.org/TR/2000/REC-xml-20001006#sec-well-formed" shape=
|
|
"rect">well-formed</a> XML document <a href="#ref-xml" shape=
|
|
"rect">[XML]</a> conforming to namespaces in XML <a href=
|
|
"#ref-xmlns" shape="rect">[XMLNS]</a></li>
|
|
<li>and it conforms to the criteria for <a href="#S5.2" shape=
|
|
"rect">Conforming Stand-Alone XML Form Grammar Document</a> after:
|
|
<ul>
|
|
<li>all non-grammar namespace elements and attributes and all
|
|
<code>xmlns</code> attributes which refer to non-grammar namespace
|
|
elements are removed from the document,</li>
|
|
<li>and, an appropriate XML declaration (i.e.,
|
|
<code><?xml...?></code>) is included at the top of the
|
|
document,</li>
|
|
<li>and, if the <code>grammar</code> element does not already
|
|
designate the grammar namespace using the "xmlns" attribute, then
|
|
<code>xmlns="http://www.w3.org/2001/06/grammar"</code> is added to
|
|
the element.</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
<h3 id="id-S5.2"><a id="S5.2" name="S5.2" shape="rect">5.2:
|
|
Conforming Stand-Alone XML Form Grammar Document</a></h3>
|
|
<p>A document is a <em>Conforming Stand-Alone XML Form Grammar
|
|
Document</em> if it meets both the following conditions.</p>
|
|
<ul>
|
|
<li>It is a <a href=
|
|
"http://www.w3.org/TR/2000/REC-xml-20001006#sec-well-formed" shape=
|
|
"rect">well-formed</a> XML document <a href="#ref-xml" shape=
|
|
"rect">[XML]</a> conforming to namespaces in XML <a href=
|
|
"#ref-xmlns" shape="rect">[XMLNS]</a>.</li>
|
|
<li>It is <a href=
|
|
"http://www.w3.org/TR/2000/REC-xml-20001006#sec-prolog-dtd" shape=
|
|
"rect">valid XML document</a> which adheres to the specification
|
|
described in this document (<a href="#S1" shape="rect">Speech
|
|
Recognition Grammar Specification</a>) including the constraints
|
|
expressed in the schema (see <a href="#AppC" shape="rect">Appendix
|
|
C</a>) and having an XML Form prolog and <grammar> root
|
|
element as specified in <a href="#S4.3" shape="rect">Section
|
|
4.3</a> and</li>
|
|
</ul>
|
|
<p>The XML Form grammar specification and these conformance
|
|
criteria provide no designated size limits on any aspect of grammar
|
|
documents. There are no maximum values on the number of elements,
|
|
the amount of character data, or the number of characters in
|
|
attribute values.</p>
|
|
<h3 id="id-S5.3"><a id="S5.3" name="S5.3" shape="rect">5.3 Using
|
|
XML Form Grammars with other Namespaces</a></h3>
|
|
<p>The grammar namespace may be used with other XML namespaces as
|
|
per the Namespaces in XML Recommendation <a href="#ref-xmlns"
|
|
shape="rect">[XMLNS]</a>. Future work by W3C will address ways to
|
|
specify conformance for documents involving multiple
|
|
namespaces.</p>
|
|
<h3 id="id-S5.4"><a id="S5.4" name="S5.4" shape="rect">5.4
|
|
Conforming XML Form Grammar Processors</a></h3>
|
|
<p>An XML Form grammar processor is a program that can parse and
|
|
process XML Form grammar documents. Examples include speech
|
|
recognizers and DTMF detectors that accept the XML Form.</p>
|
|
<p>In a <em>Conforming XML Form Grammar Processor</em>, the XML
|
|
parser must be able to parse and process all XML constructs defined
|
|
by XML 1.0 <a href="#ref-xml" shape="rect">[XML]</a> and Namespaces
|
|
in XML <a href="#ref-xmlns" shape="rect">[XMLNS]</a>. This XML
|
|
parser is not required to perform validation of a grammar document
|
|
as per its schema or DTD; this implies that during processing of an
|
|
XML Form grammar document it is optional to apply or expand
|
|
external entity references defined in an external DTD.</p>
|
|
<p>A Conforming XML Form Grammar Processor must correctly
|
|
understand and apply the semantics of each possible grammar feature
|
|
defined by this document.</p>
|
|
<p>A Conforming XML Form Grammar Processor must meet the following
|
|
requirements for handling of languages:</p>
|
|
<ul>
|
|
<li>A Conforming Grammar Processor is required to parse all legal
|
|
language declarations successfully.</li>
|
|
<li>A Conforming Grammar Processor should inform its hosting
|
|
environment if it encounters a language that it can not
|
|
support.</li>
|
|
<li>A Conforming Grammar Processor that can support a given
|
|
language, must be able to activate the root, any single public
|
|
rule, or any set of public rules or roots of one or many grammars
|
|
where each rule or root and all directly or indirectly referenced
|
|
sub-rules are for this same given language.</li>
|
|
<li>A Conforming Grammar Processor may activate a part (i.e., the
|
|
root, any single public rule, or any set of public rules) of one or
|
|
many grammars where the parts contain multiple languages, with one or
|
|
more languages in each part. When a processor is able to support each
|
|
language in the set but is unable to handle them concurrently it
|
|
should inform the hosting environment. When the set includes one or
|
|
more languages that are not supported by the processor it should
|
|
inform the hosting environment.</li>
|
|
<li>A Conforming Grammar Processor may implement languages by
|
|
approximate substitutions according to a documented,
|
|
platform-specific behavior. For example, using a US English speech
|
|
recognizer to process British English input.</li>
|
|
</ul>
|
|
<p>When a Conforming XML Form Grammar Processor encounters elements
|
|
or attributes in a non-grammar namespace it may:</p>
|
|
<ul>
|
|
<li>ignore the non-standard elements and/or attributes</li>
|
|
<li>or, process the non-standard elements and/or attributes</li>
|
|
<li>or, reject the document containing those elements and/or
|
|
attributes</li>
|
|
</ul>
|
|
<p>A Conforming XML Form Grammar Processor is not required to
|
|
support recursive grammars, that is, grammars in which <a href=
|
|
"#S2.2" shape="rect">rule references</a> include direct or indirect
|
|
self-reference.</p>
|
|
<p>There is, however, no conformance requirement with respect to
|
|
performance characteristics of the XML Form Grammar Processor. For
|
|
instance, no statement is required regarding the accuracy, speed or
|
|
other characteristics of a speech recognizer or DTMF detector. No
|
|
statement is made regarding the size of grammar or size of grammar
|
|
vocabulary that an XML Form Grammar Processor must support.</p>
|
|
<h3 id="id-S5.5"><a id="S5.5" name="S5.5" shape="rect">5.5:
|
|
Conforming Stand-Alone ABNF Form Grammar Documents</a></h3>
|
|
<p>An ABNF grammar document is a Conforming ABNF Document if it
|
|
adheres to the specification described in this document (<a href=
|
|
"#S1" shape="rect">Speech Recognition Grammar Specification</a>)
|
|
including the <a href="#AppD" shape="rect">Formal ABNF
|
|
Specification</a>.</p>
|
|
<h3 id="id-S5.6"><a id="S5.6" name="S5.6" shape="rect">5.6:
|
|
Conforming ABNF Form Grammar Processor</a></h3>
|
|
<p>An ABNF Grammar Processor is a program that can parse and
|
|
process ABNF grammar documents. Examples include speech recognizers
|
|
and DTMF detectors that accept the ABNF Form.</p>
|
|
<p>A Conforming ABNF Grammar Processor must correctly understand
|
|
and apply the semantics of each possible grammar feature defined by
|
|
this document.</p>
|
|
<p>A Conforming ABNF Grammar Processor must follow the same
|
|
language handling requirements as outlined in <a href="#S5.4"
|
|
shape="rect">Section 5.4</a> for Conforming XML Form Grammar
|
|
Processors.</p>
|
|
<p>A Conforming ABNF Grammar Processor should inform its hosting
|
|
environment if it encounters an illegal grammar document or other
|
|
grammar content that it is unable to process.</p>
|
|
<p>A Conforming ABNF Grammar Processor is not required to support
|
|
recursive grammars, that is, grammars in which <a href="#S2.2"
|
|
shape="rect">rule references</a> include direct or indirect
|
|
self-reference.</p>
|
|
<p>There is, however, no conformance requirement with respect to
|
|
performance characteristics of the ABNF Grammar Processor. For
|
|
instance, no statement is required regarding the accuracy, speed or
|
|
other characteristics of a speech recognizer or DTMF detector. No
|
|
statement is made regarding the size of grammar or size of grammar
|
|
vocabulary that an ABNF Grammar Processor must support.</p>
|
|
<h3 id="id-S5.7"><a id="S5.7" name="S5.7" shape="rect">5.7:
|
|
Conforming ABNF/XML Form Grammar Processor</a></h3>
|
|
<p>A Conforming ABNF/XML Form Grammar Processor must meet all the
|
|
conformance criteria defined in <a href="#S5.4" shape=
|
|
"rect">Section 5.4</a> and in <a href="#S5.6" shape="rect">Section
|
|
5.6</a>.</p>
|
|
<p>Additionally an ABNF/XML Form Grammar Processor must be able to
|
|
resolve and apply <a href="#S2.2" shape="rect">references</a> from
|
|
XML Form Grammars to ABNF Form Grammars, and <a href="#S2.2" shape=
|
|
"rect">references</a> from ABNF Form Grammars to XML Form
|
|
Grammars.</p>
|
|
<h3 id="id-S5.8"><a id="S5.8" name="S5.8" shape="rect">5.8:
|
|
Conforming User Agent</a></h3>
|
|
<p>A conforming user agent is a <a href="#S5.4" shape=
|
|
"rect">Conforming XML Form Grammar Processor</a>, <a href="#S5.6"
|
|
shape="rect">Conforming ABNF Form Grammar Processor</a> or <a href=
|
|
"#S5.7" shape="rect">Conforming ABNF/XML Form Grammar Processor</a>
|
|
that is capable of accepting user input of the <a href="#S4.6"
|
|
shape="rect"><code>mode</code></a> of a grammar (i.e. speech input
|
|
in <code>"voice"</code> mode, DTMF input <code>"dtmf"</code> mode)
|
|
and:</p>
|
|
<ol>
|
|
<li>Is capable of determining when a sequence of user input exactly
|
|
matches a grammar,</li>
|
|
<li>Is capable of producing an output representation that indicates
|
|
how the input matches the grammar.</li>
|
|
</ol>
|
|
<p>Current speech recognition technology is statistically based.
|
|
Since the output is not deterministic and cannot be guaranteed to
|
|
be a correct representation of the input there is no conformance
|
|
requirement regarding accuracy. A conformance test may, however,
|
|
require some examples of correct recognition of speech input to
|
|
determine conformance.</p>
|
|
<h2 id="id-S6"><a id="S6" name="S6" shape="rect">6.
|
|
Acknowledgements</a></h2>
|
|
<p>This document was written with the participation of the members
|
|
of the W3C Voice Browser Working Group <em>(listed in alphabetical
|
|
order)</em>:</p>
|
|
<dl>
|
|
<dd>Mike Brown, Lucent Bell Labs<br clear="none" />
|
|
Dan Burnett, Nuance Communications<br clear="none" />
|
|
Emily Candell, Comverse<br clear="none" />
|
|
<span>Jerry Carter, Invited Expert</span><br clear="none" />
|
|
<span>Debbie Dahl, Invited Expert</span><br clear="none" />
|
|
Debajit Ghosh, Nuance Communications<br clear="none" />
|
|
Andrew Hunt, <span>ScanSoft</span><br clear="none" />
|
|
<span>Stefan Krause, ScanSoft</span><br clear="none" />
|
|
Sol Lerner, <span>ScanSoft</span><br clear="none" />
|
|
Bruce Lucas, IBM<br clear="none" />
|
|
<span>Jens Marschner, ScanSoft</span><br clear="none" />
|
|
Scott McGlashan, <span>Hewlett-Packard</span><br clear="none" />
|
|
Yves Normandin, Locus Dialogue<br clear="none" />
|
|
Brad Porter, Tellme<br clear="none" />
|
|
<span>Dave Raggett, W3C/Canon</span><br clear="none" />
|
|
David Ramsthaler, Cisco<br clear="none" />
|
|
Luc Van Tichelen, ScanSoft<br clear="none" />
|
|
Kuansan Wang, Microsoft<br clear="none" />
|
|
Laura Werner, BeVocal<br clear="none" /></dd>
|
|
</dl>
|
|
<h2 id="id-AppA"><a id="AppA" name="AppA" shape="rect">Appendix A:
|
|
References</a></h2>
|
|
<h3 id="id-AppA.1"><a id="AppA.1" name="AppA.1" shape="rect">A.1:
|
|
Normative References</a></h3>
|
|
|
|
<dl>
|
|
<dt><a id="ref-rfc2119" name="ref-rfc2119" shape=" rect">[RFC2119]</a></dt>
|
|
<dd><cite><a href="http://www.ietf.org/rfc/rfc2119.txt">Key words for use in RFCs to Indicate
|
|
Requirement Levels</a></cite>,
|
|
S. Bradner.
|
|
IETF RFC 2119. See http://www.ietf.org/rfc/rfc2119.txt</dd>
|
|
<dt><a id="ref-rfc2045" name="ref-rfc2045" shape=" rect">[RFC2045]</a></dt>
|
|
<dd><cite><a href="http://www.ietf.org/rfc/rfc2045.txt">Multipurpose Internet Mail
|
|
Extensions (MIME) Part One: Format of Internet Message Bodies</a></cite>,
|
|
N. Freed and N. Borenstein.
|
|
|
|
IETF RFC 2045. November, 1996. See http://www.ietf.org/rfc/rfc2045.txt</dd>
|
|
|
|
<dt><a id="ref-rfc2046" name="ref-rfc2046" shape=" rect">[RFC2046]</a></dt>
|
|
<dd><cite><a href="http://www.ietf.org/rfc/rfc2046.txt">Multipurpose Internet Mail
|
|
Extensions (MIME) Part Two: Media Types</a></cite>,
|
|
N. Freed and N. Borenstein.
|
|
IETF RFC 2046.
|
|
November 1996. See http://www.ietf.org/rfc/rfc2046.txt</dd>
|
|
<dt><a id="ref-rfc2396" name="ref-rfc2396" shape=" rect">[RFC2396]</a></dt>
|
|
<dd><cite><a href="http://www.ietf.org/rfc/rfc2396.txt">Uniform Resource Identifiers (URI): Generic Syntax</a></cite>,
|
|
T. Berners-Lee, R. Fielding, U.C. Irvine, L. Masinter.
|
|
IETF
|
|
RFC 2396. 1998. See http://www.ietf.org/rfc/rfc2396.txt</dd>
|
|
<dt><a id="ref-schema1" name="ref-schema1" shape=" rect">[SCHEMA1]</a></dt>
|
|
|
|
<dd><cite><a href="http://www.w3.org/TR/xmlschema-1/">XML Schema Part 1: Structures</a></cite>,
|
|
H. S. Thompson, et al.
|
|
|
|
W3C Recommendation, May 2001. See http://www.w3.org/TR/xmlschema-1/</dd>
|
|
<dt><a id="ref-schema2" name="ref-schema2" shape=" rect">[SCHEMA2]</a></dt>
|
|
<dd><cite><a href="http://www.w3.org/TR/xmlschema-2/">XML Schema Part 2: Datatypes</a></cite>,
|
|
P.V. Biron, A. Malhotra.
|
|
|
|
W3C Recommendation, May 2001 See http://www.w3.org/TR/xmlschema-2/</dd>
|
|
<dt><a id="ref-mimetypes" name="ref-mimetypes" shape=" rect">[TYPES]</a></dt>
|
|
<dd><cite><a href="http://www.iana.org/assignments/media-types/index.html">List of media types (MIME types) registered with IANA</a></cite>.
|
|
See http://www.iana.org/assignments/media-types/index.html</dd>
|
|
<dt><a id="ref-xml" name="ref-xml" shape="rect">[XML]</a></dt>
|
|
<dd><cite><a href="http://www.w3.org/TR/2000/REC-xml-20001006">Extensible Markup Language (XML)
|
|
1.0 (Second Edition)</a></cite>,
|
|
World Wide Web Consortium.
|
|
W3C Recommendation, 6 October 2000. See
|
|
http://www.w3.org/TR/2000/REC-xml-20001006</dd>
|
|
<dt><a id="ref-xml-base" name="ref-xml-base" shape=" rect"/>[XML-BASE]</dt>
|
|
<dd><cite><a href="http://www.w3.org/TR/2001/REC-xmlbase-20010627/">XML Base</a></cite>,
|
|
J. Marsh, editor.
|
|
W3C Recommendation, June
|
|
2001. See http://www.w3.org/TR/2001/REC-xmlbase-20010627/</dd>
|
|
|
|
<dt><a id="ref-xmlns" name="ref-xmlns" shape=" rect">[XMLNS]</a></dt>
|
|
<dd><cite><a href="http://www.w3.org/TR/REC-xml-names/">Namespaces in XML</a></cite>,
|
|
World Wide Web Consortium.
|
|
W3C
|
|
Recommendation. See http://www.w3.org/TR/REC-xml-names/</dd>
|
|
</dl>
|
|
<h3 id="id-AppA.2"><a id="AppA.2" name="AppA.2" shape="rect">A.2:
|
|
Informative References</a></h3>
|
|
<dl>
|
|
<dt><a id="ref-charmod" name="ref-charmod" shape=" rect">[CHARMOD]</a></dt>
|
|
<dd><cite><a href="http://www.w3.org/TR/charmod/">Character Model for the World
|
|
Wide Web 1.0</a></cite>,
|
|
World Wide Web Consortium. W3C Working Draft, 20 December 2001. See
|
|
http://www.w3.org/TR/charmod/</dd>
|
|
<dt><a id="ref-dc" class="ref" shape="rect">[DC]</a></dt>
|
|
<dd><cite><a href="http://dublincore.org/">Dublin Core Metadata Initiative</a></cite>,
|
|
See http://dublincore.org/.</dd>
|
|
<dt><a id="ref-java" name="ref-java" shape="rect">[JAVA]</a></dt>
|
|
<dd><cite><a href="http://java.sun.com/docs/books/jls/">The Java Language
|
|
Specification (First Edition)</a></cite>,
|
|
James Gosling, Bill Joy, and Guy Steele.
|
|
Addison-Wesley. See http://java.sun.com/docs/books/jls/</dd>
|
|
|
|
<dt><a id="ref-jsgf" name="ref-jsgf" shape="rect">[JSGF]</a></dt>
|
|
<dd><cite><a href="http://www.w3.org/TR/jsgf/">JSpeech Grammar Format</a></cite>,
|
|
Sun Microsystems.
|
|
Sun
|
|
Microsystems submission to W3C. See http://www.w3.org/TR/jsgf/</dd>
|
|
<dt><a id="ref-html" name="ref-html" shape="rect">[HTML]</a></dt>
|
|
<dd><cite><a href="http://www.w3.org/TR/1999/REC-html401-19991224/">HTML 4.01 Specification.</a></cite>,
|
|
World Wide Web Consortium.
|
|
|
|
W3C Recommendation, 24 December 1999. See http://www.w3.org/TR/1999/REC-html401-19991224/</dd>
|
|
<dt><a id="ref-hu79" name="ref-hu79" shape="rect">[HU79]</a></dt>
|
|
|
|
<dd><cite><a href="">Introduction to Automata
|
|
Theory, Languages, and Computation</a></cite>,
|
|
J.E. Hopcroft and J.D. Ullman,
|
|
Addison-Wesley, 1979.</dd>
|
|
<dt><a id="ref-iso10646" name="ref-iso10646" shape="rect">[ISO/IEC
|
|
10646]</a></dt>
|
|
<dd><cite><a href="">ISO/IEC 10646-1993 (E). Information technology — Universal
|
|
Multiple-Octet Coded Character Set (UCS) — Part 1: Architecture
|
|
and Basic Multilingual Plane</a></cite>,
|
|
ISO (International Organization for Standardization).
|
|
[Geneva]: International
|
|
Organization for Standardization, 1993 (plus amendments AM 1
|
|
through AM 7).</dd>
|
|
<dt><a id="ref-jel98" name="ref-jel98" shape=" rect">[JEL98]</a></dt>
|
|
<dd><cite><a href="">Statistical methods for speech
|
|
recognition</a></cite>,
|
|
F. Jelinek.
|
|
MIT Press, 1998. ISBN: 0-262-10066-5.</dd>
|
|
|
|
<dt><a id="ref-ngram" name="ref-ngram" shape=" rect">[NGRAM]</a></dt>
|
|
<dd><cite><a href="http://www.w3.org/TR/ngram-spec/">Stochastic Language Models
|
|
(N-Gram) Specification</a></cite>,
|
|
World Wide Web Consortium.
|
|
W3C Working Draft. See http://www.w3.org/TR/ngram-spec/</dd>
|
|
<dt><a id="ref-nlsml" name="ref-nlsml" shape=" rect">[NLSML]</a></dt>
|
|
<dd><cite><a href="http://www.w3.org/TR/nl-spec/">Natural Language Semantics
|
|
Markup Language.</a></cite>,
|
|
World Wide Web Consortium,
|
|
W3C Working Draft, 20 November 2000. See
|
|
http://www.w3.org/TR/nl-spec/</dd>
|
|
<dt><a id="ref-lex" name="ref-lex" shape="rect">[LEX]</a></dt>
|
|
|
|
<dd><cite><a href="http://www.w3.org/TR/lexicon-reqs/">Pronunciation Lexicon Markup
|
|
Requirements</a></cite>,
|
|
World Wide Web Consortium,
|
|
W3C Working Draft, 12th March 2001. See http://www.w3.org/TR/lexicon-reqs/</dd>
|
|
<dt><a id="ref-q24" name="ref-q24" shape="rect">[Q24]</a></dt>
|
|
<dd><cite><a href="http://www.itu.int/home/index.html">Multifrequency
|
|
push-button signal reception</a></cite>,
|
|
International Telecommunication Union.
|
|
ITU Recommendation approved
|
|
1988-11. See http://www.itu.int/home/index.html</dd>
|
|
<dt><a id="ref-rab93" name="ref-rab93" shape=" rect">[RAB93]</a></dt>
|
|
|
|
<dd><cite><a href="">Fundamentals of Speech
|
|
Recognition</a></cite>,
|
|
L. Rabiner and B.H. Juang,
|
|
Prentice Hall, 1993. ISBN: 0-13-015157-2.</dd>
|
|
<dt><a id="ref-rdf-syntax" class="ref" shape=" rect">[RDF-SYNTAX]</a></dt>
|
|
<dd><cite><a href="http://www.w3.org/TR/1999/REC-rdf-syntax-19990222/">Resource Description Framework (RDF) Model and Syntax Specification</a></cite>,
|
|
Ora Lassila and Ralph R. Swick. W3C
|
|
Recommendation, 22 February 1999. See http://www.w3.org/TR/1999/REC-rdf-syntax-19990222/</dd>
|
|
<dt><a id="ref-rdf-schema" class="ref" shape=" rect">[RDF-SCHEMA]</a></dt>
|
|
<dd><cite><a href="http://www.w3.org/TR/2000/CR-rdf-schema-20000327/">Resource Description Framework (RDF) Schema Specification 1.0</a></cite>,
|
|
Dan Brickley and R.V. Guha.
|
|
W3C Candidate
|
|
Recommendation, March 2000. See http://www.w3.org/TR/2000/CR-rdf-schema-20000327/</dd>
|
|
|
|
<dt><a id="ref-rfc1766" name="ref-rfc1766" shape=" rect">[RFC1766]</a></dt>
|
|
<dd><cite><a href="http://www.ietf.org/rfc/rfc1766.txt">Tags for the Identification of Languages</a></cite>,
|
|
H. Alvestrand.
|
|
IETF RFC 1766. See http://www.ietf.org/rfc/rfc1766.txt</dd>
|
|
<dt><a id="ref-rfc2616" name="ref-rfc2616" shape=" rect">[RFC2616]</a></dt>
|
|
<dd><cite><a href="http://www.ietf.org/rfc/rfc2616.txt">Hypertext Transfer Protocol —
|
|
HTTP/1.1</a></cite>,
|
|
R. Fielding, et al.
|
|
IETF RFC 2616. 1999. See http://www.ietf.org/rfc/rfc2616.txt</dd>
|
|
<dt><a id="ref-rfc2732" name="ref-rfc2732" shape=" rect">[RFC2732]</a></dt>
|
|
|
|
<dd><cite><a href="http://www.ietf.org/rfc/rfc2732.txt">Format for Literal
|
|
IPv6 Addresses in URL's</a></cite>,
|
|
R. Hinden, B. Carpenter, L. Masinter.
|
|
IETF RFC 2732. 1999. See http://www.ietf.org/rfc/rfc2732.txt</dd>
|
|
<dt><a id="ref-rfc3066" name="ref-rfc3066" shape=" rect">[RFC3066]</a></dt>
|
|
<dd><cite><a href="http://www.ietf.org/rfc/rfc3066.txt">Tags for the Identification of
|
|
Languages</a></cite>,
|
|
H. Alvestrand.
|
|
IETF RFC 3066. See http://www.ietf.org/rfc/rfc3066.txt</dd>
|
|
<dt><a id="ref-sem" name="ref-sem" shape="rect">[SEM]</a></dt>
|
|
<dd><cite><a href="http://www.w3.org/TR/semantic-interpretation/">Semantic Interpretation for
|
|
Speech Recognition</a></cite>,
|
|
World Wide Web Consortium,
|
|
W3C Working Draft, 16 November 2001. See
|
|
|
|
http://www.w3.org/TR/semantic-interpretation/</dd>
|
|
<dt><a id="ref-talkml" name="ref-talkml" shape=" rect">[TALKML]</a></dt>
|
|
<dd><cite><a href="http://www.w3.org/Voice/TalkML/">Introduction to TalkML</a></cite>,
|
|
Dave Raggett.
|
|
W3C Note. See
|
|
http://www.w3.org/Voice/TalkML/</dd>
|
|
<dt><a id="ref-unicode" name="ref-unicode" shape=" rect">[Unicode]</a></dt>
|
|
<dd><cite>The Unicode Standard, Version 2.0</cite>,
|
|
The Unicode Consortium.
|
|
Reading, Mass.: Addison-Wesley Developers Press,
|
|
1996.</dd>
|
|
|
|
<dt><a id="ref-unicode3" name="ref-unicode3" shape=" rect">[Unicode3]</a></dt>
|
|
<dd><cite>The Unicode Standard, Version
|
|
3.0</cite>,
|
|
The Unicode Consortium.
|
|
Reading, Mass.: Addison-Wesley Developers Press, 2000.
|
|
ISBN 0-201-61633-5.</dd>
|
|
<dt><a id="ref-vxml1" name="ref-vxml1" shape=" rect">[VXML1]</a></dt>
|
|
<dd><cite><a href="http://www.w3.org/TR/2000/NOTE-voicexml-20000505/">Voice eXtensible Markup Language (VoiceXML)
|
|
version 1.0</a></cite>,
|
|
VoiceXML Forum.
|
|
W3C Note, 05 May 2000. See http://www.w3.org/TR/2000/NOTE-voicexml-20000505/</dd>
|
|
<dt><a id="ref-vxml2" name="ref-vxml2" shape=" rect">[VXML2]</a></dt>
|
|
|
|
<dd><cite><a href="http://www.w3.org/TR/2001/WD-voicexml20-20011023/">Voice Extensible Markup Language
|
|
(VoiceXML) Version 2.0</a></cite>,
|
|
World Wide Web Consortium.
|
|
W3C Working Draft, 23 October 2001.
|
|
See http://www.w3.org/TR/2001/WD-voicexml20-20011023/</dd>
|
|
</dl>
|
|
|
|
|
|
<h2 id="id-AppB"><a id="AppB" name="AppB" shape="rect">Appendix B:
|
|
|
|
|
|
DTD for XML Form Grammars</a></h2>
|
|
<p><b>This appendix is informative.</b></p>
|
|
<p>The grammar DTD is located at <a href="grammar.dtd" shape=
|
|
"rect">http://www.w3.org/TR/speech-grammar/grammar.dtd</a></p>
|
|
<h2 id="id-AppC"><a id="AppC" name="AppC" shape="rect">Appendix C:
|
|
XML Schema Definition For XML Form Grammars</a></h2>
|
|
<p><b>This appendix is normative.</b></p>
|
|
<p>The grammar schema is located at <a href="grammar.xsd" shape=
|
|
"rect">http://www.w3.org/TR/speech-grammar/grammar.xsd</a></p>
|
|
<p>Note: the grammar schema includes the <a href=
|
|
"#schema-no-namespace" shape="rect">no-namespace core schema</a>
|
|
(below).</p>
|
|
<p><a id="schema-no-namespace" name="schema-no-namespace" shape=
|
|
"rect"></a> The <em>no-namespace core schema</em> for grammars is
|
|
located at <a href="grammar-core.xsd" shape=
|
|
"rect">http://www.w3.org/TR/speech-grammar/grammar-core.xsd</a>. It
|
|
may be used as a basis for specifying XML Form Grammar Fragments
|
|
embedded in non-grammar namespace schemas.</p>
|
|
<h2 id="id-AppD"><a id="AppD" name="AppD" shape="rect">Appendix D:
|
|
Formal Syntax for Augmented BNF Form Grammars</a></h2>
|
|
<p><b>This appendix is normative.</b></p>
|
|
<p>The notation used here follows the <a href=
|
|
"http://www.w3.org/TR/2000/REC-xml-20001006#sec-notation" shape=
|
|
"rect">EBNF notation</a> (Extended Backus-Naur Form) defined in the
|
|
XML 1.0 Recommendation <a href="#ref-xml" shape="rect">[XML
|
|
§6]</a>.</p>
|
|
<p>The <a href="#term-whitespace" shape="rect">white space handling
|
|
of the ABNF Form</a> follows white space and end-of-line handling
|
|
of XML (see <a href="#S1.6" shape="rect">Section 1.6</a>).</p>
|
|
<p><b>Lexical Grammar for ABNF</b></p>
|
|
<p>The lexical grammar defines the lexical tokens of the ABNF
|
|
format and has single characters as its terminal symbols. As a
|
|
consequence neither <a href="#term-whitespace" shape=
|
|
"rect">white space</a> characters nor <a href="#S4.13" shape=
|
|
"rect">ABNF comments</a> are allowed in lexical tokens unless
|
|
explicitly specified.</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
SelfIdentHeader ::=
|
|
'#ABNF' #x20 VersionNumber (#x20 CharEncoding)? ';'
|
|
<em>[Additional constraints:
|
|
- The semicolon (';') must immediately be followed
|
|
by an <a href="#term-whitespace" shape=
|
|
"rect">end-of-line</a>.
|
|
]</em>
|
|
|
|
VersionNumber ::=
|
|
'1.0'
|
|
|
|
CharEncoding ::=
|
|
Nmtoken
|
|
|
|
BaseURI ::=
|
|
ABNF_URI
|
|
|
|
LanguageCode ::=
|
|
Nmtoken
|
|
<i>[Additional constraints:
|
|
- The language code must be a valid <a href=
|
|
"#term-language" shape="rect">language identifier</a>.
|
|
]</i>
|
|
|
|
RuleName ::=
|
|
'$' ConstrainedName
|
|
|
|
ConstrainedName ::=
|
|
Name - (Char* ('.' | ':' | '-') Char*)
|
|
|
|
TagFormat ::=
|
|
ABNF_URI
|
|
|
|
LexiconURI ::=
|
|
ABNF_URI | ABNF_URI_with_Media_Type
|
|
|
|
SingleQuotedCharacters ::=
|
|
''' [^']* '''
|
|
|
|
DoubleQuotedCharacters ::=
|
|
'"' [^"]* '"'
|
|
|
|
QuotedCharacters ::=
|
|
SingleQuotedCharacters | DoubleQuotedCharacters
|
|
|
|
Weight ::=
|
|
'/' Number '/'
|
|
|
|
|
|
Repeat ::=
|
|
[0-9]+ ('-' [0-9]*)?
|
|
<em>[Additional constraints:
|
|
- A number to the right of the hyphen must not be
|
|
greater than the number to the left of the hyphen.
|
|
]</em>
|
|
|
|
|
|
Probability ::=
|
|
'/' Number '/'
|
|
<i>[Additional constraints:
|
|
- The float value must be in the range of "0.0"
|
|
to "1.0" (inclusive).
|
|
]</i>
|
|
|
|
Number ::=
|
|
[0-9]+ | [0-9]+ '.' [0-9]* | [0-9]* '.' [0-9]+
|
|
|
|
ExternalRuleRef ::=
|
|
'$' ABNF_URI | '$' ABNF_URI_with_Media_Type
|
|
<i>[Additional constraints:
|
|
- The referenced grammar must have the same mode
|
|
("voice" or "dtmf") as the referencing grammar.
|
|
- If the URI reference contains a fragment
|
|
identifier, the referenced rule must be a
|
|
public rule of another grammar.
|
|
- If the URI reference does not contain a fragment
|
|
identifier, i.e. if it is a<span>n implicit</span> root rule reference,
|
|
then the referenced grammar must declare a root
|
|
rule.
|
|
]</i>
|
|
|
|
Token ::=
|
|
Nmtoken | DoubleQuotedCharacters
|
|
|
|
LanguageAttachment ::=
|
|
'!' LanguageCode
|
|
|
|
Tag ::=
|
|
'{' [^}]* '}'
|
|
| '{!{' (Char* - (Char* '}!}' Char*)) '}!}'
|
|
|
|
------------------------------------------------------------
|
|
|
|
<b><a href="#term-uri" shape="rect">ABNF_URI</a>
|
|
</b> and <b><a href="#term-media-type" shape=
|
|
"rect">ABNF_URI_with_Media_Type</a>
|
|
</b> are defined
|
|
in <a href="#S1.6" shape="rect">Section 1.6 Terminology</a>.
|
|
|
|
<b>Name</b> is defined by the XML <a href=
|
|
"http://www.w3.org/TR/2000/REC-xml-20001006#NT-Name" shape=
|
|
"rect">Name</a> production <a href="#ref-xml" shape=
|
|
"rect">[XML §2.3]</a>.
|
|
|
|
<b>Nmtoken</b> is defined by the XML <a href=
|
|
"http://www.w3.org/TR/2000/REC-xml-20001006#NT-Nmtoken" shape=
|
|
"rect">Nmtoken</a> production <a href="#ref-xml" shape=
|
|
"rect">[XML §2.3]</a>.
|
|
|
|
<b>NameChar</b> is defined by the XML <a href=
|
|
"http://www.w3.org/TR/2000/REC-xml-20001006#NT-NameChar" shape=
|
|
"rect">NameChar</a> production <a href="#ref-xml" shape=
|
|
"rect">[XML §2.3]</a>.
|
|
|
|
<b>Char</b> is defined by the XML <a href=
|
|
"http://www.w3.org/TR/2000/REC-xml-20001006#NT-Char" shape=
|
|
"rect">Char</a> production <a href="#ref-xml" shape=
|
|
"rect">[XML §2.2]</a>.
|
|
</pre>
|
|
<p>Note: As mentioned in <a href="#S2.5" shape="rect">Section
|
|
2.5</a> the symbols "*", "+" and "?", which are often used in
|
|
regular expression languages, are reserved for future use in ABNF
|
|
and must not be used at any place in a grammar where the syntax
|
|
currently permits a repeat operator.</p>
|
|
<p><b>Syntactic Grammar for ABNF</b></p>
|
|
<p>The syntactic grammar has lexical tokens defined by the lexical
|
|
grammar as its terminal symbols. Between two lexical tokens any
|
|
number of <a href="#term-whitespace" shape="rect">white spaces</a>
|
|
or <a href="#S4.13" shape="rect">ABNF comments</a> may appear.</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
grammar ::=
|
|
SelfIdentHeader declaration* ruleDefinition*
|
|
|
|
declaration ::=
|
|
baseDecl | languageDecl | modeDecl | rootRuleDecl
|
|
| tagFormatDecl | lexiconDecl | metaDecl <span>| tagDecl</span>
|
|
|
|
baseDecl ::=
|
|
'base' BaseURI ';'
|
|
<i>[Additional constraints:
|
|
- A base declaration must not appear more than
|
|
once in grammar.
|
|
]</i>
|
|
|
|
languageDecl ::=
|
|
'language' LanguageCode ';'
|
|
<i>[Additional constraints:
|
|
- A language declaration must not appear more than
|
|
once in grammar.
|
|
- A language declaration is required if the
|
|
grammar mode is "voice".
|
|
]</i>
|
|
|
|
modeDecl ::=
|
|
'mode' 'voice' ';' | 'mode' 'dtmf' ';'
|
|
<i>[Additional constraints:
|
|
- A mode declaration must not appear more than
|
|
once in grammar.
|
|
]</i>
|
|
|
|
rootRuleDecl ::=
|
|
'root' RuleName ';'
|
|
<i>[Additional constraints:
|
|
- A root rule declaration must not appear more
|
|
than once in grammar.
|
|
- The root rule must be a rule that is defined
|
|
within the grammar.
|
|
]</i>
|
|
|
|
tagFormatDecl ::=
|
|
'tag-format' TagFormat ';'
|
|
<i>[Additional constraints:
|
|
- A tag-format declaration must not appear more
|
|
than once in grammar.
|
|
]</i>
|
|
|
|
lexiconDecl ::=
|
|
'lexicon' LexiconURI ';'
|
|
|
|
metaDecl ::=
|
|
'http-equiv' QuotedCharacters 'is' QuotedCharacters ';'
|
|
| 'meta' QuotedCharacters 'is' QuotedCharacters ';'
|
|
|
|
<span>
|
|
tagDecl ::=
|
|
Tag ';'
|
|
</span>
|
|
|
|
ruleDefinition ::=
|
|
scope? RuleName '=' ruleExpansion ';'
|
|
<i>[Additional constraints:
|
|
- The rule name must be unique within a grammar,
|
|
i.e. no rule must be defined more than once
|
|
within a grammar.
|
|
]</i>
|
|
|
|
scope ::=
|
|
'private' | 'public'
|
|
|
|
ruleExpansion ::=
|
|
ruleAlternative ( '|' ruleAlternative )*
|
|
|
|
ruleAlternative ::=
|
|
Weight? sequenceElement+
|
|
|
|
sequenceElement ::=
|
|
subexpansion | subexpansion repeatOperator
|
|
|
|
subexpansion ::=
|
|
Token LanguageAttachment?
|
|
| ruleRef
|
|
| Tag
|
|
| '(' ')'
|
|
| '(' ruleExpansion ')' LanguageAttachment?
|
|
| '[' ruleExpansion ']' LanguageAttachment?
|
|
|
|
ruleRef ::=
|
|
localRuleRef | ExternalRuleRef | specialRuleRef
|
|
|
|
localRuleRef ::=
|
|
RuleName
|
|
<i>[Additional constraints:
|
|
- The referenced rule must be defined within the
|
|
same grammar.
|
|
]</i>
|
|
|
|
specialRuleRef ::=
|
|
'$NULL' | '$VOID' | '$GARBAGE'
|
|
|
|
|
|
repeatOperator ::=
|
|
'<' Repeat Probability? '>'
|
|
</pre>
|
|
<h2 id="id-AppE"><a id="AppE" name="AppE" shape="rect">Appendix E:
|
|
DTMF Grammars</a></h2>
|
|
<p><b>This appendix is normative.</b></p>
|
|
<p>This section defines a normative representation of a grammar
|
|
consisting of <a href="#term-dtmf" shape="rect">DTMF</a> tokens. A
|
|
DTMF grammar can be used by a DTMF detector to determine sequences
|
|
of legal and illegal DTMF events. All grammar processors that
|
|
support grammars of mode <code>"dtmf"</code> must implement this
|
|
Appendix. However, not all grammar processors are required to
|
|
support DTMF input.</p>
|
|
<p>If the <a href="#S4.6" shape="rect">grammar mode</a> is declared
|
|
as "dtmf" then <a href="#S2.1" shape="rect">tokens</a> contained by
|
|
the grammar are treated as DTMF tones (rather than the default of
|
|
speech tokens).</p>
|
|
<p>There are sixteen (16) DTMF tones. Of these twelve (12) are
|
|
commonly found on telephone sets as the digits "0" through "9" plus
|
|
"*" (star) and "#" (pound). The four DTMF tones not typically
|
|
present on telephones are "A", "B", "C", "D".</p>
|
|
<p>Each of the DTMF symbols is a legal DTMF token in a DTMF
|
|
grammar. As in speech grammars, tokens must be separated by
|
|
<a href="#term-whitespace" shape="rect">white space</a> in a DTMF
|
|
grammar. A space-separated sequence of DTMF symbols represents a
|
|
temporal sequence of DTMF entries.</p>
|
|
<p>In the ABNF Form the "*" symbol is reserved so double quotes
|
|
must always be used to delimit "*" when defining an ABNF DTMF
|
|
grammar. It is recommended that the "#" symbol also be quoted. As
|
|
an alternative the tokens "star" and "pound" are acceptable
|
|
synonyms.</p>
|
|
<p>In any DTMF grammar any <a href="#S4.5" shape="rect">language
|
|
declaration</a> in a grammar header is ignored and any <a href=
|
|
"#S2.7" shape="rect">language attachments</a> to rule expansions
|
|
are ignored.</p>
|
|
<p>In all other respects a DTMF grammar is syntactically the same
|
|
as a speech grammar. For example, DTMF grammars may use <a href=
|
|
"#S2.2" shape="rect">rule references</a>, <a href="#S2.2.3" shape=
|
|
"rect">special rules</a>, <a href="#S2.6" shape="rect">tags</a> and
|
|
other specification features.</p>
|
|
<p>The following is a simple DTMF grammar that accepts a 4-digit
|
|
PIN followed by a pound terminator. It also permits the sequence of
|
|
"*" followed by "9" (e.g. to receive a help message).</p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
#ABNF 1.0 ISO-8859-1;
|
|
|
|
mode dtmf;
|
|
|
|
$digit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
public $pin = $digit <4> "#" | "*" 9;
|
|
</pre>
|
|
<pre class="xml" xml:space="preserve">
|
|
<?xml version="1.0"?>
|
|
|
|
<grammar mode="dtmf" version="1.0"
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://www.w3.org/2001/06/grammar
|
|
http://www.w3.org/TR/speech-grammar/grammar.xsd"
|
|
xmlns="http://www.w3.org/2001/06/grammar">
|
|
|
|
<rule id="digit">
|
|
<one-of>
|
|
<item> 0 </item>
|
|
<item> 1 </item>
|
|
<item> 2 </item>
|
|
<item> 3 </item>
|
|
<item> 4 </item>
|
|
<item> 5 </item>
|
|
<item> 6 </item>
|
|
<item> 7 </item>
|
|
<item> 8 </item>
|
|
<item> 9 </item>
|
|
</one-of>
|
|
</rule>
|
|
|
|
<rule id="pin" scope="public">
|
|
<one-of>
|
|
<item>
|
|
<item repeat="4"><ruleref uri="#digit"/></item>
|
|
#
|
|
</item>
|
|
<item>
|
|
* 9
|
|
</item>
|
|
</one-of>
|
|
</rule>
|
|
|
|
</grammar>
|
|
</pre>
|
|
<h2 id="id-AppF"><a id="AppF" name="AppF" shape="rect">Appendix F:
|
|
XSLT Style Sheet to Convert XML Form Grammars to ABNF Form</a></h2>
|
|
<p><b>This appendix is informative.</b></p>
|
|
<p>The transformation provided below is illustrative of the
|
|
conversion of an XML Form grammar to the Augmented BNF Form. Known
|
|
limitations:</p>
|
|
<ul>
|
|
<li>Comments are not transformed</li>
|
|
<li>There is no treatment of empty token elements (which are
|
|
illegal in ABNF)</li>
|
|
<li>Preserves filenames (e.g. "grammar.grxml") and media types
|
|
('application/srgs+xml') in URIs and media type declarations.</li>
|
|
<li>Assumes the quoted content within <meta> attributes uses
|
|
double quotes. Does not correctly convert <meta> attributes
|
|
containing single quotes.</li>
|
|
</ul>
|
|
<p>The source for this transformation is located at <a href=
|
|
"grammar-transformer.xsl" shape=
|
|
"rect">http://www.w3.org/TR/speech-grammar/grammar-transformer.xsl</a>.</p>
|
|
<h2 id="id-AppG"><a id="AppG" name="AppG" shape="rect">Appendix G.
|
|
Media Types and File Suffix</a></h2>
|
|
<p><b>This appendix is informative.</b></p>
|
|
<p>The W3C Voice Browser Working Group has applied to IANA to
|
|
register a <a href="#term-media-type" shape="rect">media type</a>
|
|
each for the ABNF Form and XML Form of this Speech Recognition
|
|
Grammar Specification.</p>
|
|
|
|
<ul>
|
|
<li>
|
|
<p>The ABNF media type identifies ABNF grammars. The media type
|
|
applied for is <code>"application/srgs"</code>.</p>
|
|
</li>
|
|
<li>
|
|
<p>Similarly, the XML Form grammar media type identifies XML
|
|
Form grammars. The media type applied for is
|
|
<code>"application/srgs+xml"</code>.</p>
|
|
</li>
|
|
</ul>
|
|
<p>The W3C Voice Browser Working Group has adopted the convention
|
|
of using the ".gram" filename suffix for ABNF grammar documents and
|
|
the ".grxml" filename suffix for XML Form grammar documents.</p>
|
|
<h2 id="id-AppH"><a id="AppH" name="AppH" shape="rect">Appendix H.
|
|
Logical Parse Structure</a></h2>
|
|
<p><b>This appendix is informative.</b></p>
|
|
<p>This section defines an informative representation of a parsed
|
|
result of speech recognition or other user agent processing. This
|
|
representation may be used as the basis for subsequent processing
|
|
of user input, in particular, <a href="#S1.4" shape="rect">semantic
|
|
interpretation</a>. For instance, the W3C Semantic Interpretation
|
|
for Speech Recognition specification <a href="#ref-sem" shape=
|
|
"rect">[SEM]</a> is defined around the logical parse structure.</p>
|
|
<h3 id="id-AppH.1"><a id="AppH.1" name="AppH.1" shape="rect">H.1
|
|
Terminology and Notation</a></h3>
|
|
<p>This Appendix adopts the terminology and nomenclature of
|
|
<em>Introduction to Automata Theory, Languages, and
|
|
Computation</em> <a href="#ref-hu79" shape="rect">[HU79]</a>.</p>
|
|
<p>Denote the <em>tokens</em> of the alphabet of all tokens
|
|
accepted by a grammar as <b>t1, t2...</b>.</p>
|
|
<p>An input or output token sequence is a space separated string of
|
|
tokens. The logical parse structure contains <a href="#S2.1" shape=
|
|
"rect">white-space-normalized tokens</a>. The tokens in the logical
|
|
parse structure are optionally delimited by double quotes so that
|
|
<a href="#term-whitespace" shape="rect">white space</a> and others
|
|
characters can be parsed unambiguously. e.g. <b>t1,t2,"t3 with
|
|
space"</b>. (For consistency, all examples in this Appendix include
|
|
double quotes.)</p>
|
|
<p>Let <b>ε</b> (epsilon) or "" denote the unique string of
|
|
length 0, also known as the empty string.</p>
|
|
<p>Denote the <em>tags</em> of the alphabet of all tags accepted by
|
|
a grammar as <b>{tag1}, {tag2}, ...</b>.</p>
|
|
<p>Denote a legal expansion as <b>E</b>. (A legal expansion is
|
|
defined in <a href="#S2" shape="rect">Section 2</a>.)</p>
|
|
<p>The expressive power of a rule expansion is a <em>Regular
|
|
Expression</em> (see HU79) and has an equivalent <em>Finite
|
|
Automaton</em> (see HU79). [The handling of rule references
|
|
requires special treatment: see <a href="#AppH.2" shape=
|
|
"rect">Section H.2</a>.] The expressive power of the grammar
|
|
specification consists of:</p>
|
|
<ul>
|
|
<li>Tokens: a finite automaton transition with symbol</li>
|
|
<li>Tag: a finite automaton transition on ε</li>
|
|
<li>Sequence: concatenation operation on finite automaton</li>
|
|
<li>Alternatives: union operation on finite automaton</li>
|
|
<li>Repeats: representable by combinations of concatenation,
|
|
closure and union.</li>
|
|
</ul>
|
|
<p>We formalize the logical parse structure by creating a
|
|
<em>Finite Automaton with Output</em> (see HU79). This construct is
|
|
also referred to as a <em>Finite State Transducer</em>.</p>
|
|
<p>We define the transitions for tokens and tags as producing an
|
|
output symbol.</p>
|
|
<ul>
|
|
<li>Token: transition that accepts token <b>t</b> and produces as
|
|
output token <b>t</b>.<br clear="none" />
|
|
In the notation of HU79: <b>t/t</b></li>
|
|
<li>Tag: transition that accepts ε (no token) and produces
|
|
as output <b>{!{tag}!}</b><br clear="none" />
|
|
In the notation of HU79: <b>ε/{!{tag}!}</b></li>
|
|
</ul>
|
|
<p>We represent parse output as an ordered array of output
|
|
entities: <b>[e1,e2,e3,...]</b>.</p>
|
|
<p>An entity <b>e</b> may be a token, a tag or a rule expansion
|
|
(see <a href="#AppH.2" shape="rect">H.2</a>).</p>
|
|
<p>The empty output array is represented as <b>[ε]</b> or
|
|
simply <b>[]</b>.</p>
|
|
<h4 id="AppH.1-special">Special Cases</h4>
|
|
<p>A $NULL reference is equivalent to a transition that accepts as
|
|
input ε and produces as output ε. In the notation
|
|
of HU79: <b>ε/ε</b>.</p>
|
|
<p>A $VOID reference is logically equivalent to a missing
|
|
transition. It accepts no input and produces no output.</p>
|
|
<p>A $GARBAGE reference is equivalent to a transition that accepts
|
|
platform specific input and produces as output ε.</p>
|
|
<h4 id="AppH.1-amb">Ambiguity</h4>
|
|
<p>An <em>ambiguity</em> occurs when for a specified sequence of
|
|
input tokens matched to a specified rule of a grammar there is more
|
|
than one distinct logical parse structure that can be produced.</p>
|
|
<p>An <em>ambiguity</em> can occur at points of disjunction
|
|
(choice) in a grammar. Disjunction exists with the use of <a href=
|
|
"#S2.4" shape="rect">alternatives</a> and <a href="#S2.5" shape=
|
|
"rect">repeats</a>.</p>
|
|
<p>A grammar processor may preserve any number of ambiguous logical
|
|
parse structures to create a set of alternative logical parse
|
|
structures for the input. It is legal for a grammar processor to
|
|
maintain all possible logical parse structures or to dispose of all
|
|
but one of the alternatives. There is no specified behavior for
|
|
selection of ambiguities amongst possibilities by a grammar
|
|
processors. As a result grammars that contain ambiguity do not
|
|
guarantee portability of performance. Developers and grammar tools
|
|
should be ambiguity-aware.</p>
|
|
<p>This Appendix does not illustrate all forms of ambiguous
|
|
expansions but provides examples of some of the form common
|
|
forms.</p>
|
|
<h4 id="AppH.1-examples">Examples</h4>
|
|
<p>Matching a token to a token produces an array of 1 token.</p>
|
|
<table summary="" border="1" cellpadding="3">
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Expansion</em></td>
|
|
<td colspan="1" rowspan="1">t1</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Input</em></td>
|
|
<td colspan="1" rowspan="1">t1</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output</em></td>
|
|
<td colspan="1" rowspan="1">["t1"]</td>
|
|
</tr>
|
|
</table>
|
|
<p>A $NULL reference is matched by an empty input sequence and
|
|
output is an empty array.</p>
|
|
<table summary="" border="1" cellpadding="3">
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Expansion</em></td>
|
|
<td colspan="1" rowspan="1">$NULL</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Input</em></td>
|
|
<td colspan="1" rowspan="1">""</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output</em></td>
|
|
<td colspan="1" rowspan="1">[]</td>
|
|
</tr>
|
|
</table>
|
|
<p>A tag is matched by an empty input sequence and output is an
|
|
array of 1 tag.</p>
|
|
<table summary="" border="1" cellpadding="3">
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Expansion</em></td>
|
|
<td colspan="1" rowspan="1">{tag} or {!{tag}!}</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Input</em></td>
|
|
<td colspan="1" rowspan="1">""</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output</em></td>
|
|
<td colspan="1" rowspan="1">[{!{tag}!}]</td>
|
|
</tr>
|
|
</table>
|
|
<p>Concatenation: An expansion consisting of a token and a tag is
|
|
matched by input containing the token and produces as output a
|
|
token, tag array.</p>
|
|
<table summary="" border="1" cellpadding="3">
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Expansion</em></td>
|
|
<td colspan="1" rowspan="1">t1 {tag1}</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Input</em></td>
|
|
<td colspan="1" rowspan="1">t1</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output</em></td>
|
|
<td colspan="1" rowspan="1">["t1",{!{tag1}!}]</td>
|
|
</tr>
|
|
</table>
|
|
<p>Concatenation: an expansion consisting of a sequence of tokens,
|
|
tags and $NULLs is matched by input that consists of the contained
|
|
tokens. Output consists of the sequence of tokens and tags with
|
|
order preserved. e.g.</p>
|
|
<table summary="" border="1" cellpadding="3">
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Expansion</em></td>
|
|
<td colspan="1" rowspan="1">t1 $NULL {tag1} t2 {tag2} t3</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Input</em></td>
|
|
<td colspan="1" rowspan="1">t1 t2 t3</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output</em></td>
|
|
<td colspan="1" rowspan="1">
|
|
["t1",{!{tag1}!},"t2",{!{tag2}!},"t3"]</td>
|
|
</tr>
|
|
</table>
|
|
<p>Parenthetical structure is not preserved in the result. The
|
|
following is the same sequence as the previous example but with
|
|
parentheticals added to the expansion definition.</p>
|
|
<table summary="" border="1" cellpadding="3">
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Expansion</em></td>
|
|
<td colspan="1" rowspan="1">((t1) $NULL) {tag1} (t2 {tag2} t3)</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Input</em></td>
|
|
<td colspan="1" rowspan="1">t1 t2 t3</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output</em></td>
|
|
<td colspan="1" rowspan="1">
|
|
["t1",{!{tag1}!},"t2",{!{tag2}!},"t3"]</td>
|
|
</tr>
|
|
</table>
|
|
<p>Alternatives: a set of many alternative tokens is matched by
|
|
input of a single token and produces as output a single token.</p>
|
|
<table summary="" border="1" cellpadding="3">
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Expansion</em></td>
|
|
<td colspan="1" rowspan="1">t1 | t2 |t3</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Input</em></td>
|
|
<td colspan="1" rowspan="1">t2</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output</em></td>
|
|
<td colspan="1" rowspan="1">["t2"]</td>
|
|
</tr>
|
|
</table>
|
|
<p>Alternatives: if any single expansion in a set of alternatives
|
|
can be matched by null input then the set of alternatives may be
|
|
matched by null input and the output is the output of
|
|
null-accepting expansion. ($NULL, {tag} and repeat counts of zero
|
|
all permit null input.)</p>
|
|
<table summary="" border="1" cellpadding="3">
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Expansion</em></td>
|
|
<td colspan="1" rowspan="1">t1 | t2 | $NULL</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Input</em></td>
|
|
<td colspan="1" rowspan="1">""</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output</em></td>
|
|
<td colspan="1" rowspan="1">[]</td>
|
|
</tr>
|
|
</table>
|
|
<p>With a different null-accepting expansion:</p>
|
|
<table summary="" border="1" cellpadding="3">
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Expansion</em></td>
|
|
<td colspan="1" rowspan="1">t1 | t2 | {tag}</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Input</em></td>
|
|
<td colspan="1" rowspan="1">""</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output</em></td>
|
|
<td colspan="1" rowspan="1">[{!{tag}!}]</td>
|
|
</tr>
|
|
</table>
|
|
<p>Alternatives and ambiguity: several examples of ambiguous
|
|
expansions with the ambiguity arising from alternatives that accept
|
|
the same input but produce different output.</p>
|
|
<table summary="" border="1" cellpadding="3">
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Expansion</em></td>
|
|
<td colspan="1" rowspan="1">t1 {tag1} | t1 {tag2} | t2</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Input</em></td>
|
|
<td colspan="1" rowspan="1">t1</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output 1</em></td>
|
|
<td colspan="1" rowspan="1">["t1",{!{tag1}!}]</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output 2</em></td>
|
|
<td colspan="1" rowspan="1">["t1",{!{tag2}!}]</td>
|
|
</tr>
|
|
</table>
|
|
<p>In this example null input is ambiguous.</p>
|
|
<table summary="" border="1" cellpadding="3">
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Expansion</em></td>
|
|
<td colspan="1" rowspan="1">{tag1} | {tag2} | $NULL</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Input</em></td>
|
|
<td colspan="1" rowspan="1">""</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output 1</em></td>
|
|
<td colspan="1" rowspan="1">[{!{tag1}!}]</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output 2</em></td>
|
|
<td colspan="1" rowspan="1">[{!{tag2}!}]</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output 3</em></td>
|
|
<td colspan="1" rowspan="1">[]</td>
|
|
</tr>
|
|
</table>
|
|
<p>The following is not ambiguous because the different paths
|
|
through the expansion produce the same output.</p>
|
|
<table summary="" border="1" cellpadding="3">
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Expansion</em></td>
|
|
<td colspan="1" rowspan="1">t1 | t1 | t2</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Input</em></td>
|
|
<td colspan="1" rowspan="1">t1</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output 1</em></td>
|
|
<td colspan="1" rowspan="1">["t1"]</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output 2</em></td>
|
|
<td colspan="1" rowspan="1">["t1"]</td>
|
|
</tr>
|
|
</table>
|
|
<p>Repeats: an optional expansion can be either matched by an empty
|
|
token sequence or by any token sequence that matches the expansion
|
|
contained within the optional.</p>
|
|
<table summary="" border="1" cellpadding="3">
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Expansion</em></td>
|
|
<td colspan="1" rowspan="1">t1 <0-1></td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Input 1</em></td>
|
|
<td colspan="1" rowspan="1">""</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output 1</em></td>
|
|
<td colspan="1" rowspan="1">[]</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Input 2</em></td>
|
|
<td colspan="1" rowspan="1">t1</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output 2</em></td>
|
|
<td colspan="1" rowspan="1">["t1"]</td>
|
|
</tr>
|
|
</table>
|
|
<p>Repeats: order is preserved upon multiple expansions.</p>
|
|
<table summary="" border="1" cellpadding="3">
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Expansion</em></td>
|
|
<td colspan="1" rowspan="1">(t1 {tag1}) <0-3></td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Input 1</em></td>
|
|
<td colspan="1" rowspan="1">""</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output 1</em></td>
|
|
<td colspan="1" rowspan="1">[]</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Input 2</em></td>
|
|
<td colspan="1" rowspan="1">t1</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output 2</em></td>
|
|
<td colspan="1" rowspan="1">["t1",{!{tag1}!}]</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Input 3</em></td>
|
|
<td colspan="1" rowspan="1">t1,t1,t1</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output 3</em></td>
|
|
<td colspan="1" rowspan="1">
|
|
["t1",{!{tag1}!},"t1",{!{tag1}!},"t1",{!{tag1}!}]</td>
|
|
</tr>
|
|
</table>
|
|
<p>Repeats and null input: If the contents of an optional expansion
|
|
can be matched by an empty input sequence AND the output of
|
|
matching the contained expansion is always an empty array then the
|
|
output of matching the optional expansion by an empty sequence is
|
|
also an empty array.</p>
|
|
<table summary="" border="1" cellpadding="3">
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Expansion</em></td>
|
|
<td colspan="1" rowspan="1">$NULL <0-1></td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Input</em></td>
|
|
<td colspan="1" rowspan="1">""</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output</em></td>
|
|
<td colspan="1" rowspan="1">[]</td>
|
|
</tr>
|
|
</table>
|
|
<p>Ambiguous repeats: If a repeated or optional expansion can be
|
|
matched by an empty input sequence BUT the output of matching the
|
|
contained expansion may contain tags then the parse is ambiguous.
|
|
It is <em>recommended</em> that the parse be minimal: Output 1 is
|
|
preferred.</p>
|
|
<table summary="" border="1" cellpadding="3">
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Expansion</em></td>
|
|
<td colspan="1" rowspan="1">{tag} <0-></td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Input</em></td>
|
|
<td colspan="1" rowspan="1">""</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output 1</em></td>
|
|
<td colspan="1" rowspan="1">[]</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output 2</em></td>
|
|
<td colspan="1" rowspan="1">[{!{tag}!}]</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output 3</em></td>
|
|
<td colspan="1" rowspan="1">[{!{tag}!},{!{tag}!}]</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output N</em></td>
|
|
<td colspan="1" rowspan="1">
|
|
[{!{tag}!},{!{tag}!},{!{tag}!},...]</td>
|
|
</tr>
|
|
</table>
|
|
<p>A similar ambiguity arises if the repeated expansion contains a
|
|
alternative expansion that has a null-accepting expansion.</p>
|
|
<table summary="" border="1" cellpadding="3">
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Expansion</em></td>
|
|
<td colspan="1" rowspan="1">(t1 | {tag}) <0-3></td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Input</em></td>
|
|
<td colspan="1" rowspan="1">t1</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output 1</em></td>
|
|
<td colspan="1" rowspan="1">["t1"]</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output 2</em></td>
|
|
<td colspan="1" rowspan="1">["t1",{!{tag}!}]</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output 3</em></td>
|
|
<td colspan="1" rowspan="1">[{!{tag}!},"t1"]</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output 4</em></td>
|
|
<td colspan="1" rowspan="1">["t1",{!{tag}!},{!{tag}!}]</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output 5</em></td>
|
|
<td colspan="1" rowspan="1">[{!{tag}!},"t1",{!{tag}!}]</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output 6</em></td>
|
|
<td colspan="1" rowspan="1">[{!{tag}!},{!{tag}!},"t1"]</td>
|
|
</tr>
|
|
</table>
|
|
<p>A sequence with two repeat expansion can be ambiguous if the two
|
|
repeated expansions can accept the same input but produce different
|
|
output.</p>
|
|
<table summary="" border="1" cellpadding="3">
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Expansion</em></td>
|
|
<td colspan="1" rowspan="1">(t1 {tag1}) <0-2> (t1 {tag2})
|
|
<0-2></td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Input</em></td>
|
|
<td colspan="1" rowspan="1">t1,t1,t1</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output 1</em></td>
|
|
<td colspan="1" rowspan="1">
|
|
["t1",{!{tag1}!},"t1",{!{tag1}!},"t1",{!{tag1}!}</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output 2</em></td>
|
|
<td colspan="1" rowspan="1">
|
|
["t1",{!{tag1}!},"t1",{!{tag1}!},"t1",{!{tag2}!}</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output 3</em></td>
|
|
<td colspan="1" rowspan="1">
|
|
["t1",{!{tag1}!},"t1",{!{tag2}!},"t1",{!{tag2}!}</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output 4</em></td>
|
|
<td colspan="1" rowspan="1">
|
|
["t1",{!{tag2}!},"t1",{!{tag2}!},"t1",{!{tag2}!}</td>
|
|
</tr>
|
|
</table>
|
|
<h3 id="id-AppH.2"><a id="AppH.2" name="AppH.2" shape="rect">H.2
|
|
Parsing Rule References</a></h3>
|
|
<p>A rule reference is a legal rule expansion (see <a href="#S2.2"
|
|
shape="rect">Section 2.2</a>).</p>
|
|
<p>We denote output obtained by matching the token sequence
|
|
<b>"t1,t2,..."</b> against the expansion <b>$rulename</b> as
|
|
<b>$rulename[e1,e2,...]</b> where <b>"e1,e2,..."</b> is the entity
|
|
sequence obtained by matching that token sequence against the rule
|
|
expansion defined for $rulename. Where a rule reference to an
|
|
external rule is used the ABNF syntax for the rule reference is
|
|
used (without any media type). For example,
|
|
<code>$<http://www.example.com/grammar.<span>grxml</span>#rulename">[e1,e2,...]</code>
|
|
or a<span>n implicit</span> root rule reference
|
|
<code>$<http://www.example.com/grammar.<span>grxml</span>">[e1,e2,...]</code>.
|
|
For brevity, all the examples below use only local rule
|
|
references.</p>
|
|
<p>The rulename of the top-level rule should enclose the logical
|
|
parse structure.</p>
|
|
<p>A distinct structure for matching rule references maintains the
|
|
parse tree for the result. This structure may be utilized in the
|
|
semantic interpretation process or other computational processes
|
|
that derive from the parse output structure.</p>
|
|
<p>There is no distinction between <a href="#S2.2.1" shape=
|
|
"rect">local rule references</a> (within the same grammar) and
|
|
<a href="#S2.2.2" shape="rect">external rule references</a>.</p>
|
|
<p>There is no distinction between a root reference and a reference
|
|
to a named grammar.</p>
|
|
<h4 id="AppH.2.example">Examples</h4>
|
|
<p>The following is a simple rule reference example.</p>
|
|
<table summary="" border="1" cellpadding="3">
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Rule</em></td>
|
|
<td colspan="1" rowspan="1">$x = t1 t2 t3;</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Expansion</em></td>
|
|
<td colspan="1" rowspan="1">$x</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Input</em></td>
|
|
<td colspan="1" rowspan="1">t1,t2,t3</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output</em></td>
|
|
<td colspan="1" rowspan="1">$x["t1","t2","t3"]</td>
|
|
</tr>
|
|
</table>
|
|
<p>The following is a rule reference in sequence.</p>
|
|
<table summary="" border="1" cellpadding="3">
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Rule</em></td>
|
|
<td colspan="1" rowspan="1">$x = t2 t3 t4;</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Expansion</em></td>
|
|
<td colspan="1" rowspan="1">t1 $x t5</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Input</em></td>
|
|
<td colspan="1" rowspan="1">t1,t2,t3,t4,t5</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output</em></td>
|
|
<td colspan="1" rowspan="1">["t1",$x["t2","t3","t4"],"t5"]</td>
|
|
</tr>
|
|
</table>
|
|
<p>The following includes a reference to a rule that outputs a
|
|
tag.</p>
|
|
<table summary="" border="1" cellpadding="3">
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Rule</em></td>
|
|
<td colspan="1" rowspan="1">$x = t2 {tag};</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Expansion</em></td>
|
|
<td colspan="1" rowspan="1">t1 $x t3</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Input</em></td>
|
|
<td colspan="1" rowspan="1">t1,t2,t3</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output</em></td>
|
|
<td colspan="1" rowspan="1">["t1",$x["t2",{!{tag}!}],"t3"]</td>
|
|
</tr>
|
|
</table>
|
|
<p>Multiple references to the same rule are permitted.</p>
|
|
<table summary="" border="1" cellpadding="3">
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Rule</em></td>
|
|
<td colspan="1" rowspan="1">$x = t1 {tag1};</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Expansion</em></td>
|
|
<td colspan="1" rowspan="1">$x $x $x</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Input</em></td>
|
|
<td colspan="1" rowspan="1">t1,t1,t1</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output</em></td>
|
|
<td colspan="1" rowspan="1">
|
|
[$x["t1",{!{tag1}!}],$x["t1",{!{tag1}!}],$x["t1",{!{tag1}!}]]</td>
|
|
</tr>
|
|
</table>
|
|
<p>Rule references may be repeated.</p>
|
|
<table summary="" border="1" cellpadding="3">
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Rule</em></td>
|
|
<td colspan="1" rowspan="1">$x = t1 {tag};</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Expansion</em></td>
|
|
<td colspan="1" rowspan="1">$x <0-></td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Input</em></td>
|
|
<td colspan="1" rowspan="1">t1,t1,t1</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output</em></td>
|
|
<td colspan="1" rowspan="1">
|
|
[$x["t1",{!{tag1}!}],$x["t1",{!{tag1}!}],$x["t1",{!{tag1}!}]]</td>
|
|
</tr>
|
|
</table>
|
|
<h3 id="id-AppH.3"><a id="AppH.3" name="AppH.3" shape="rect">H.3
|
|
Recursion</a></h3>
|
|
<p>The Speech Recognition Grammar Specification has the expressive
|
|
power of a <em>Context Free Grammar</em>. This arises because the
|
|
language permits a rule to directly or indirectly reference itself.
|
|
[Note: a <a href="#S5.4" shape="rect">Conforming XML Form Grammar
|
|
Processor</a> or <a href="#S5.6" shape="rect">Conforming ABNF Form
|
|
Grammar Processor</a> is not required to support recursive
|
|
grammars.]</p>
|
|
<p>There is no distinct representation for a recursive rule
|
|
reference.</p>
|
|
<h4 id="AppH.3.examples">Examples</h4>
|
|
<p>Simple right recursion. Note: this grammar can be written in a
|
|
non-recursive (regular expression) form.</p>
|
|
<table summary="" border="1" cellpadding="3">
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Rule</em></td>
|
|
<td colspan="1" rowspan="1">$x = t1 {last} | t1 $x;</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Expansion</em></td>
|
|
<td colspan="1" rowspan="1">$x</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Input</em></td>
|
|
<td colspan="1" rowspan="1">t1,t1,t1</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output</em></td>
|
|
<td colspan="1" rowspan="1">
|
|
[$x["t1",$x["t1",$x["t1",{!{last}!}]]]]</td>
|
|
</tr>
|
|
</table>
|
|
<p>Embedded recursion. Note that this matches any sequence of
|
|
<em>n</em> t1's followed by <em>n</em> t2's.</p>
|
|
<table summary="" border="1" cellpadding="3">
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Rule</em></td>
|
|
<td colspan="1" rowspan="1">$x = {bottom} | (t1 $x t2);</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Expansion</em></td>
|
|
<td colspan="1" rowspan="1">$x</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Input</em></td>
|
|
<td colspan="1" rowspan="1">t1,t1,t2,t2</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="1" rowspan="1"><em>Output</em></td>
|
|
<td colspan="1" rowspan="1">
|
|
[$x["t1",$x["t1",$x[{!{bottom}!}],"t2"],"t2"]]</td>
|
|
</tr>
|
|
</table>
|
|
<h2 id="id-AppI"><a id="AppI" name="AppI" shape="rect">Appendix I.
|
|
Features under Consideration for Future Versions</a></h2>
|
|
<p><b>This appendix is informative.</b></p>
|
|
<p>The following features are under consideration for versions of
|
|
the Speech Recognition Grammar Specification after version 1.0:</p>
|
|
<ul>
|
|
<li>Optimizations for dynamic grammars: e.g. "static" or "volatile"
|
|
keywords on rule definitions.</li>
|
|
<li>Dynamic variation of weights on alternatives</li>
|
|
<li>Definition of grammar fragments</li>
|
|
<li>Specified handling of morphological variants of tokens</li>
|
|
<li>Inline definition of token pronunciations</li>
|
|
<li>Guidance to recognizers on acoustic models</li>
|
|
<li>Support for W3C pronunciation lexicon when it is available</li>
|
|
<li>Declaration of semantic return types of rules</li>
|
|
<li>Possible distinction of "activable" and "exported" rules
|
|
(currently merged as "public")</li>
|
|
<li>Multi-modal grammars: e.g. speech and DTMF mixed, speech and
|
|
keyboard, speech and pointer...</li>
|
|
<li>Conformance criteria for grammar generators</li>
|
|
<li>Support for timeout parameters within grammars (e.g.
|
|
inter-digit timeout for DTMF)</li>
|
|
<li>Support for long DTMF tones — e.g. accept a tone of 1000ms or
|
|
longer</li>
|
|
<li>XLink for URI references</li>
|
|
</ul>
|
|
<h2 id="id-AppJ"><a id="AppJ" name="AppJ" shape="rect">Appendix J:
|
|
Example Grammars in ABNF Form and XML Form</a></h2>
|
|
<p><b>This appendix is informative.</b></p>
|
|
<ul>
|
|
<li class="tocline">J.1 <a href="#AppJ.1" shape="rect">Simple
|
|
Examples (English)</a></li>
|
|
<li class="tocline">J.2 <a href="#AppJ.2" shape=
|
|
"rect">Cross-Reference Examples (English)</a></li>
|
|
<li class="tocline">J.3 <a href="#AppJ.3" shape="rect">Korean
|
|
Examples</a></li>
|
|
<li class="tocline">J.4 <a href="#AppJ.4" shape="rect">Chinese
|
|
Examples</a></li>
|
|
<li class="tocline">J.5 <a href="#AppJ.5" shape="rect">Swedish
|
|
Examples</a></li>
|
|
</ul>
|
|
<h3 id="id-AppJ.1"><a id="AppJ.1" name="AppJ.1" shape="rect">J.1:
|
|
Simple Examples (English)</a></h3>
|
|
<p>The following shows a simple grammar that supports commands such
|
|
as "open a file" and "please move the window". It references a
|
|
separately-defined grammar for politeness which is not shown
|
|
here.</p>
|
|
<blockquote>
|
|
<h4 id="AppJ.1-abnf">ABNF Form</h4>
|
|
<pre class="abnf" xml:space="preserve">
|
|
#ABNF 1.0 UTF-8;
|
|
|
|
language en;
|
|
mode voice;
|
|
root $basicCmd;
|
|
|
|
meta "author" is "Stephanie Williams";
|
|
|
|
/**
|
|
* Basic command.
|
|
* @example please move the window
|
|
* @example open a file
|
|
*/
|
|
|
|
public $basicCmd =
|
|
$<http://grammar.example.com/politeness.gram#startPolite>
|
|
$command
|
|
$<http://grammar.example.com/politeness.gram#endPolite>;
|
|
|
|
$command = $action $object;
|
|
$action = /10/ open {<a href="#S1.4" shape=
|
|
"rect">TAG-CONTENT-1</a>} | /2/ close {<a href="#S1.4" shape=
|
|
"rect">TAG-CONTENT-2</a>}
|
|
| /1/ delete {<a href="#S1.4" shape=
|
|
"rect">TAG-CONTENT-3</a>} | /1/ move {<a href="#S1.4" shape=
|
|
"rect">TAG-CONTENT-4</a>};
|
|
$object = [the | a] (window | file | menu);
|
|
</pre>
|
|
<h4 id="AppJ.1-xml">XML Form</h4>
|
|
<pre class="xml" xml:space="preserve">
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<!DOCTYPE grammar PUBLIC "-//W3C//DTD GRAMMAR 1.0//EN"
|
|
"http://www.w3.org/TR/speech-grammar/grammar.dtd">
|
|
|
|
<grammar xmlns="http://www.w3.org/2001/06/grammar" xml:lang="en"
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://www.w3.org/2001/06/grammar
|
|
http://www.w3.org/TR/speech-grammar/grammar.xsd"
|
|
version="1.0" mode="voice" root="basicCmd">
|
|
|
|
<meta name="author" content="Stephanie Williams"/>
|
|
|
|
<rule id="basicCmd" scope="public">
|
|
<example> please move the window </example>
|
|
<example> open a file </example>
|
|
|
|
<ruleref uri="http://grammar.example.com/politeness.<span>grxml</span>#startPolite"/>
|
|
|
|
<ruleref uri="#command"/>
|
|
<ruleref uri="http://grammar.example.com/politeness.<span>grxml</span>#endPolite"/>
|
|
|
|
</rule>
|
|
|
|
<rule id="command">
|
|
<ruleref uri="#action"/> <ruleref uri="#object"/>
|
|
</rule>
|
|
|
|
<rule id="action">
|
|
<one-of>
|
|
<item weight="10"> open <tag><a href="#S1.4"
|
|
shape="rect">TAG-CONTENT-1</a></tag> </item>
|
|
<item weight="2"> close <tag><a href="#S1.4"
|
|
shape="rect">TAG-CONTENT-2</a></tag> </item>
|
|
<item weight="1"> delete <tag><a href="#S1.4"
|
|
shape="rect">TAG-CONTENT-3</a></tag> </item>
|
|
<item weight="1"> move <tag><a href="#S1.4"
|
|
shape="rect">TAG-CONTENT-4</a></tag> </item>
|
|
</one-of>
|
|
</rule>
|
|
|
|
<rule id="object">
|
|
<item repeat="0-1">
|
|
<one-of>
|
|
<item> the </item>
|
|
<item> a </item>
|
|
</one-of>
|
|
</item>
|
|
|
|
<one-of>
|
|
<item> window </item>
|
|
<item> file </item>
|
|
<item> menu </item>
|
|
</one-of>
|
|
</rule>
|
|
|
|
</grammar>
|
|
</pre></blockquote>
|
|
<h3 id="id-AppJ.2"><a id="AppJ.2" name="AppJ.2" shape="rect">J.2:
|
|
Cross-Reference Examples (English)</a></h3>
|
|
<p>These two grammars illustrate referencing between grammars. The
|
|
same grammar is shown in both XML Form and ABNF Form.</p>
|
|
<blockquote>
|
|
<p><b>ABNF: http://www.example.com/places.gram</b></p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
#ABNF 1.0 ISO-8859-1;
|
|
|
|
language en;
|
|
mode voice;
|
|
root $city_state;
|
|
|
|
public $city = Boston | Philadelphia | Fargo;
|
|
|
|
public $state = Florida | North Dakota | New York;
|
|
|
|
// References to local rules
|
|
// Artificial example allows "Boston, Florida!"
|
|
|
|
public $city_state = $city $state;
|
|
</pre>
|
|
<p><b>ABNF: http://www.example.com/booking.gram</b></p>
|
|
<pre class="abnf" xml:space="preserve">
|
|
#ABNF 1.0 ISO-8859-1;
|
|
|
|
language en;
|
|
mode voice;
|
|
|
|
// Reference by URI syntax
|
|
public $flight = I want to fly to
|
|
$<http://www.example.com/places.gram#city>;
|
|
|
|
// Reference by URI syntax
|
|
public $exercise = I want to walk to $<http://www.example.com/places.gram#state>;
|
|
|
|
// <span>Implicit</span> reference to root rule by URI
|
|
public $wet = I want to swim to $<http://www.example.com/places.gram>;
|
|
</pre>
|
|
<p><b>XML Form Grammar:
|
|
http://www.example.com/places.<span>grxml</span></b></p>
|
|
<pre class="xml" xml:space="preserve">
|
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
|
|
|
<!DOCTYPE grammar PUBLIC "-//W3C//DTD GRAMMAR 1.0//EN"
|
|
"http://www.w3.org/TR/speech-grammar/grammar.dtd">
|
|
|
|
<grammar xmlns="http://www.w3.org/2001/06/grammar"
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://www.w3.org/2001/06/grammar
|
|
http://www.w3.org/TR/speech-grammar/grammar.xsd"
|
|
xml:lang="en" version="1.0" root="city_state" mode="voice">
|
|
|
|
<rule id="city" scope="public">
|
|
<one-of>
|
|
<item>Boston</item>
|
|
<item>Philadelphia</item>
|
|
<item>Fargo</item>
|
|
</one-of>
|
|
</rule>
|
|
|
|
<rule id="state" scope="public">
|
|
<one-of>
|
|
<item>Florida</item>
|
|
<item>North Dakota</item>
|
|
<item>New York</item>
|
|
</one-of>
|
|
</rule>
|
|
|
|
<!-- Reference by URI to a local rule -->
|
|
<!-- Artificial example allows "Boston, Florida"! -->
|
|
<rule id="city_state" scope="public">
|
|
<ruleref uri="#city"/> <ruleref uri="#state"/>
|
|
</rule>
|
|
</grammar>
|
|
</pre>
|
|
<p><b>XML Form Grammar:
|
|
http://www.example.com/booking.<span>grxml</span></b></p>
|
|
<pre class="xml" xml:space="preserve">
|
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
|
|
|
<!DOCTYPE grammar PUBLIC "-//W3C//DTD GRAMMAR 1.0//EN"
|
|
"http://www.w3.org/TR/speech-grammar/grammar.dtd">
|
|
|
|
<grammar xmlns="http://www.w3.org/2001/06/grammar"
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://www.w3.org/2001/06/grammar
|
|
http://www.w3.org/TR/speech-grammar/grammar.xsd"
|
|
xml:lang="en" version="1.0" mode="voice">
|
|
|
|
<!-- Using URI syntax -->
|
|
<rule id="flight" scope="public">
|
|
I want to fly to
|
|
<ruleref uri="http://www.example.com/places.<span>grxml</span>#city"/>
|
|
</rule>
|
|
|
|
<!-- Using URI syntax -->
|
|
<rule id="exercise" scope="public">
|
|
I want to walk to <ruleref uri="http://www.example.com/places.<span>grxml</span>#state"/>
|
|
|
|
</rule>
|
|
|
|
<!-- <span>Implicit</span> reference to root rule of a grammar by URI -->
|
|
<rule id="wet" scope="public">
|
|
I want to swim to <ruleref uri="http://www.example.com/places.<span>grxml</span>"/>
|
|
|
|
</rule>
|
|
</grammar>
|
|
</pre></blockquote>
|
|
<h3 id="id-AppJ.3"><a id="AppJ.3" name="AppJ.3" shape="rect">J.3:
|
|
Korean Examples</a></h3>
|
|
<p>The following two grammars are XML Form grammars with Korean
|
|
yes/no content. The first represents the Korean symbols as Unicode
|
|
characters and has UTF-8 encoding. The second represents the same
|
|
Unicode characters using character escaping.</p>
|
|
<blockquote>
|
|
<h4 id="AppJ.3-abnf">ABNF Form Grammar with Unicode Characters in
|
|
UTF-8 Encoding</h4>
|
|
<pre class="xml" xml:space="preserve">
|
|
#ABNF 1.0 UTF-8;
|
|
|
|
language ko;
|
|
mode voice;
|
|
root $yes_no_ko;
|
|
|
|
/*
|
|
* Simple Korean yes/no grammar
|
|
* @example 예
|
|
*/
|
|
|
|
public $yes_no_ko = 예 | 아니오 ;
|
|
</pre>
|
|
<h4 id="AppJ.3-xml">XML Form Grammar with Unicode Characters in
|
|
UTF-8 Encoding</h4>
|
|
<pre class="xml" xml:space="preserve">
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<!DOCTYPE grammar PUBLIC "-//W3C//DTD GRAMMAR 1.0//EN"
|
|
"http://www.w3.org/TR/speech-grammar/grammar.dtd">
|
|
|
|
<grammar xml:lang="ko" version="1.0" mode="voice"
|
|
xmlns="http://www.w3.org/2001/06/grammar"
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://www.w3.org/2001/06/grammar
|
|
http://www.w3.org/TR/speech-grammar/grammar.xsd"
|
|
root="yes_no_ko">
|
|
|
|
<!-- yes/no grammar -->
|
|
<rule id="yes_no_ko" scope="public">
|
|
<example>예</example>
|
|
<one-of>
|
|
<item>예</item>
|
|
<item>아니오</item>
|
|
</one-of>
|
|
</rule>
|
|
</grammar>
|
|
</pre>
|
|
<h4 id="AppJ.3-xml-esc">XML Form Grammar with Character Escaping of
|
|
Unicode Characters</h4>
|
|
<pre class="xml" xml:space="preserve">
|
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
|
|
|
<!DOCTYPE grammar PUBLIC "-//W3C//DTD GRAMMAR 1.0//EN"
|
|
"http://www.w3.org/TR/speech-grammar/grammar.dtd">
|
|
|
|
<grammar xml:lang="ko" version="1.0" mode="voice"
|
|
xmlns="http://www.w3.org/2001/06/grammar"
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://www.w3.org/2001/06/grammar
|
|
http://www.w3.org/TR/speech-grammar/grammar.xsd"
|
|
root="main">
|
|
|
|
<!-- yes/no grammar -->
|
|
<rule id="yes_no_ko" scope="public">
|
|
<example>&#50696;</example>
|
|
<one-of>
|
|
<item>&#50696;</item>
|
|
<item>&#50500;&#45768;&#50724;</item>
|
|
</one-of>
|
|
</rule>
|
|
</grammar>
|
|
</pre></blockquote>
|
|
<h3 id="id-AppJ.4"><a id="AppJ.4" name="AppJ.4" shape="rect">J.4:
|
|
Chinese Examples</a></h3>
|
|
<p>The following two grammars are XML Form grammars with Chinese
|
|
number content. The first represents the Chinese symbols as Unicode
|
|
characters with the UTF-8 encoding. The second represents the same
|
|
Unicode characters using character escaping.</p>
|
|
<blockquote>
|
|
<h4 id="AppJ.4-abnf">ABNF Form Grammar with Unicode Characters in
|
|
UTF-8 Encoding</h4>
|
|
<pre class="xml" xml:space="preserve">
|
|
#ABNF 1.0 UTF-8;
|
|
|
|
language zh;
|
|
mode voice;
|
|
root $main;
|
|
|
|
public $main = $digits1_9;
|
|
|
|
/*
|
|
* @example 四
|
|
*/
|
|
|
|
private $digits1_9 = 一 | 二 | 三 | 四 | 五 | 六 | 七 | 八 | 九;
|
|
</pre>
|
|
<h4 id="AppJ.4-xml">XML Form Grammar with Unicode Characters in
|
|
UTF-8 Encoding</h4>
|
|
<pre class="xml" xml:space="preserve">
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<!DOCTYPE grammar PUBLIC "-//W3C//DTD GRAMMAR 1.0//EN"
|
|
"http://www.w3.org/TR/speech-grammar/grammar.dtd">
|
|
|
|
<grammar version="1.0" xmlns="http://www.w3.org/2001/06/grammar"
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://www.w3.org/2001/06/grammar
|
|
http://www.w3.org/TR/speech-grammar/grammar.xsd"
|
|
xml:lang="zh" mode="voice" root="main">
|
|
|
|
<rule id="main" scope="public">
|
|
<ruleref uri="#digits1_9"/>
|
|
</rule>
|
|
|
|
<rule id="digits1_9" scope="private">
|
|
<example>四</example>
|
|
<one-of>
|
|
<item>一</item>
|
|
<item>二</item>
|
|
<item>三</item>
|
|
<item>四</item>
|
|
<item>五</item>
|
|
<item>六</item>
|
|
<item>七</item>
|
|
<item>八</item>
|
|
<item>九</item>
|
|
</one-of>
|
|
</rule>
|
|
</grammar>
|
|
</pre>
|
|
<h4 id="AppJ.4-xml-esc">XML Form Grammar with Character Escaping of
|
|
Unicode Characters</h4>
|
|
<pre class="xml" xml:space="preserve">
|
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
|
|
|
<!DOCTYPE grammar PUBLIC "-//W3C//DTD GRAMMAR 1.0//EN"
|
|
"http://www.w3.org/TR/speech-grammar/grammar.dtd">
|
|
|
|
<grammar version="1.0" xmlns="http://www.w3.org/2001/06/grammar"
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://www.w3.org/2001/06/grammar
|
|
http://www.w3.org/TR/speech-grammar/grammar.xsd"
|
|
xml:lang="zh" mode="voice" root="main">
|
|
|
|
<rule id="main" scope="public">
|
|
<ruleref uri="#digits1_9"/>
|
|
</rule>
|
|
|
|
<rule id="digits1_9" scope="private">
|
|
<example>&#22235;</example>
|
|
<one-of>
|
|
<item>&#19968;</item>
|
|
<item>&#20108;</item>
|
|
<item>&#19977;</item>
|
|
<item>&#22235;</item>
|
|
<item>&#20116;</item>
|
|
<item>&#20845;</item>
|
|
<item>&#19971;</item>
|
|
<item>&#20843;</item>
|
|
<item>&#20061;</item>
|
|
</one-of>
|
|
</rule>
|
|
</grammar>
|
|
</pre></blockquote>
|
|
<h3 id="id-AppJ.5"><a id="AppJ.5" name="AppJ.5" shape="rect">J.5:
|
|
Swedish Examples</a></h3>
|
|
<p>This Swedish XML Form grammar provides a comprehensive set of
|
|
forms of "yes" and "no". All characters are contained within the
|
|
ISO-8859-1 (Latin-1) character set.</p>
|
|
<blockquote>
|
|
<h4 id="AppJ.5-abnf">XML Form Grammar with ISO-8859-1</h4>
|
|
<pre class="xml" xml:space="preserve">
|
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
|
|
|
<!DOCTYPE grammar PUBLIC "-//W3C//DTD GRAMMAR 1.0//EN"
|
|
"http://www.w3.org/TR/speech-grammar/grammar.dtd">
|
|
|
|
<grammar version="1.0" xmlns="http://www.w3.org/2001/06/grammar"
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://www.w3.org/2001/06/grammar
|
|
http://www.w3.org/TR/speech-grammar/grammar.xsd"
|
|
xml:lang="sv" mode="voice" root="main">
|
|
|
|
<rule id="main" scope="public">
|
|
<example>ja det är rätt</example>
|
|
<example>nej det är fel</example>
|
|
<one-of>
|
|
<item>
|
|
<ruleref uri="#yes_rule"/>
|
|
</item>
|
|
<item>
|
|
<ruleref uri="#no_rule"/>
|
|
</item>
|
|
</one-of>
|
|
</rule>
|
|
|
|
<rule id="yes_rule" scope="private">
|
|
<example>ja det är rätt</example>
|
|
<one-of>
|
|
<item>exakt</item>
|
|
<item>javisst</item>
|
|
<item>
|
|
ja
|
|
<item repeat="0-1">
|
|
<ruleref uri="#yes_emphasis"/>
|
|
</item>
|
|
</item>
|
|
<item>jepp</item>
|
|
<item>korrekt</item>
|
|
<item>okej</item>
|
|
<item>rätt</item>
|
|
<item>si</item>
|
|
<item>säkert</item>
|
|
<item>visst</item>
|
|
</one-of>
|
|
</rule>
|
|
|
|
<rule id="yes_emphasis" scope="private">
|
|
<example>det stämmer</example>
|
|
<one-of>
|
|
<item>det gjorde jag</item>
|
|
<item>
|
|
<item repeat="0-1">det</item>
|
|
stämmer
|
|
</item>
|
|
<item>det är rätt</item>
|
|
<item>det är korrekt</item>
|
|
<item>det är riktigt</item>
|
|
</one-of>
|
|
</rule>
|
|
|
|
<rule id="no_rule" scope="private">
|
|
<example>nej det är fel</example>
|
|
<one-of>
|
|
<item>icke</item>
|
|
<item>fel</item>
|
|
<item>
|
|
nej
|
|
<item repeat="0-1">
|
|
<ruleref uri="#no_emphasis"/>
|
|
</item>
|
|
</item>
|
|
<item>nix</item>
|
|
<item>no</item>
|
|
</one-of>
|
|
</rule>
|
|
|
|
<rule id="no_emphasis" scope="private">
|
|
<example>det är fel</example>
|
|
<one-of>
|
|
<item>det gjorde jag inte</item>
|
|
<item>
|
|
<item repeat="0-1">det</item>
|
|
stämmer inte
|
|
</item>
|
|
<item>det är fel</item>
|
|
<item>absolut inte</item>
|
|
<item>inte alls</item>
|
|
</one-of>
|
|
</rule>
|
|
</grammar>
|
|
</pre></blockquote>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|
|
|