Rss Categories


Reference Number: AA-01063 Views: 3617 0 Rating/ Voters

Tags are special grammar tokens that can contain any information you wish to put in them. They are useful in transforming output, e.g. an application might accept "Yes," "Yeah," or "Yes please" but wish to return "TRUE" regardless of which is actually spoken. Using tags in conjunction with Semantic Interpretation for Speech Recognition (SISR), the standard method of placing semantic interpretation information inside of grammars, is the mechanism for transforming a specific input (or range of inputs) into the desired output.

Tags are placed inside of ABNF grammars using curly braces (the { } characters) and in GrXML using the <tag> element. In both ABNF and GrXML, the content inside a tag is identical.

ABNF Example

$yes = (yes | yeah | yes please) { out="TRUE" };

GrXML Example

<rule id="yes">
  <item>yes please</item>

Because SISR also allows for ECMAScript (JavaScript) code that treats the curly brace as a reserved character, ABNF tags can also be enclosed by a three character sequence of curly brace, exclamation point, curly brace (the {!{ and }!} sequence of characters). Both methods of denoting tags are equivalent, except the {!{ method allows you to use single curly braces within the tag. GrXML does not require anything special to use curly braces within a tag.

SISR is a very powerful method of putting extra information inside of tags. For details about it, you can see our Introduction to Semantic Interpretation which contains an SISR tutorial.

In order to use SISR within an ABNF grammar, you include a tag-format declaration in your grammar's header, like so:

#ABNF 1.0 UTF-8;
language en-US;
mode voice;
tag-format <semantics/1.0>;

The tag format must be enclosed within angle brackets. 

In GrXML, it is done as an attribute of the <grammar> element:

<grammar xmlns="" xml:lang="en-US" root="yesorno" mode="voice" tag-format="semantics/1.0">

See our list of tag formats for the acceptable formats you may declare.

You may continue on to Applying Grammar Weights, the next chapter in the grammar tutorial.