Semantic Grammar Tags
Tags are special grammar tokens that can contain any information you wish to put in them. They are useful for transforming output — for example, an application might accept "Yes," "Yeah," or "Yes please" but return "TRUE" regardless of which is spoken. Using tags together with Semantic Interpretation for Speech Recognition (SISR) — the standard method of embedding semantic interpretation information inside grammars — is the mechanism for mapping a specific input (or range of inputs) to a desired output.
Tags are placed inside ABNF grammars using curly braces ({ }) and in GrXML using the <tag> element. In both formats, the content inside a tag is identical.
ABNF example:
| $yes = (yes | yeah | yes please) { out="TRUE" }; |
GrXML example:
| <rule id="yes"> <one-of> <item>yes</item> <item>yeah</item> <item>yes please</item> </one-of> <tag>out="TRUE"</tag> </rule> |
Because SISR allows ECMAScript (JavaScript) code, which treats the curly brace as a reserved character, ABNF tags can also be enclosed with the three-character sequences {!{ and }!}. Both methods are equivalent, except that {!{ allows single curly braces to appear within the tag itself. GrXML does not require anything special to use curly braces within a tag.
SISR is a powerful method of embedding extra information inside tags. For a tutorial and further details, see the Introduction to Semantic Interpretation.
Declaring the Tag Format
To use SISR within an ABNF grammar, include a tag-format declaration in the grammar header:
| #ABNF 1.0 UTF-8; language en-US; mode voice; tag-format <semantics/1.0>; |
The tag-format value must be enclosed within angle brackets.
In GrXML, it is set as an attribute of the <grammar> element:
| <grammar xmlns="http://www.w3.org/2001/06/grammar" xml:lang="en-US" root="yesorno" mode="voice" tag-format="semantics/1.0"> |
See the list of tag formats for the acceptable formats you may declare.
Related Articles
- Introduction to Semantic Interpretation — SISR tutorial.
- Tag Format
- Applying Grammar Weights — the next step in the tutorial.
