Serialization of the Root Rule Variable (RRV)
Upon recognition, the semantic interpretation mechanism of the Microsoft Speech Application SDK Version 1.1 (SASDK) returns a semantic result to the speech-enabled Web application. The semantic result of a recognition is the value of the root Rule Variable (RRV) of the grammar. Like all Rule Variables, the RRV is predefined as an object and is identified by a dollar sign ("$").
For an input grammar that contains no markup for semantic interpretation, the SML output consists of a top-level node named SML that contains the recognized utterance. The SML start tag contains three attributes named "confidence," "text," and "utteranceConfidence." The following example illustrates a simple grammar that contains no markup for semantic interpretation.
<grammar version="1.0" xmlns="http://www.w3.org/2001/06/grammar"
root="destination" xml:lang="en-US" tag-format="semantics-ms/1.0">
<rule id="destination">
Fly me to
<one-of>
<item>London</item>
<item>Paris</item>
<item>Berlin</item>
</one-of>
</rule>
</grammar>
Using this grammar, the utterance, "Fly me to Paris," produces the following SML output:
<SML confidence="0.874" text="Fly me to Paris" utteranceConfidence="0.874">
Fly me to Paris
</SML>
Refer to SML Output Overview for more information on the structure of SML output, and the value types and ranges of these attributes in the SML element.
Simple Assignment to the RRV
If a developer directly assigns a simple scalar value to the RRV, all the properties of the RRV that the semantic interpreter normally uses for serialization are lost. The semantic interpreter produces an output in which the top-level SML element has no attributes, and contains the simple scalar value. In the following grammar, each of the expressions contained in the tag elements assigns a simple string value to the RRV.
<grammar version="1.0" xmlns="http://www.w3.org/2001/06/grammar"
root="destination" xml:lang="en-US" tag-format="semantics-ms/1.0">
<rule id="destination">
Fly me to
<one-of>
<item>London<tag>$="Heathrow.";</tag></item>
<item>Paris<tag>$="Orly.";</tag></item>
<item>Berlin<tag>$="Tegel.";</tag></item>
</one-of>
</rule>
</grammar>
Using this grammar, the utterance, "Fly me to Paris on Wednesday," produces the following SML output:
<SML>Orly.</SML>
Special Properties of Rule Variables
Every Rule Variable, including the root Rule Variable, is predefined as an object. Properties of every Rule Variable appear in SML output as child nodes with two exceptions:
- The _value property produces the text content of a node
- The _attributes property produces XML attributes in the start tag of a node
The _value Property of the RRV
Use the _value property of the RRV to set the text content of the top-level SML element. The following grammar is identical to the previous grammar except for the addition of an expression that assigns a value to the _value property of the RRV.
<grammar version="1.0" xmlns="http://www.w3.org/2001/06/grammar"
root="destination" xml:lang="en-US" tag-format="semantics-ms/1.0">
<rule id="destination">
<tag>$._value="Destination city."</tag>
Fly me to
<one-of>
<item>London</item>
<item>Paris</item>
<item>Berlin</item>
</one-of>
</rule>
</grammar>
Using this grammar, the utterance, "Fly me to Paris," produces the following SML output:
<SML confidence="0.874" text="Fly me to Paris" utteranceConfidence="0.874">
Destination city.
</SML>
All valid utterances for this grammar produce an SML result that has the same text content in the top-level SML element. This result occurs because the script expression assigning the value of the text content follows the start tag of the rule element. For grammars that contain one-of lists, change the value of the text content of the SML element according to the item selected from a list. Follow each item element with a tag element containing a script expression that assigns a different value to the _value property of the RRV. The following grammar is identical to the previous grammar except for the addition of script expressions that create SML element text content that is specific to each item.
<grammar version="1.0" xmlns="http://www.w3.org/2001/06/grammar"
root="destination" xml:lang="en-US" tag-format="semantics-ms/1.0">
<rule id="destination">
Fly me to
<one-of>
<item>London<tag>$._value="Arriving at Heathrow.";</tag></item>
<item>Paris<tag>$._value="Arriving at Orly.";</tag></item>
<item>Berlin<tag>$._value="Arriving at Tegel.";</tag></item>
</one-of>
</rule>
</grammar>
Using this grammar, the utterance, "Fly me to Paris," produces the following SML output:
<SML confidence="0.886" text="Fly me to Paris" utteranceConfidence="0.886">
Arriving at Orly.
</SML>
_attributes Property of the RRV
Use the _attributes property of the RRV to produce additional XML attributes in the top-level SML element start tag. The following grammar is identical to the previous grammar except for the addition of expressions that assign values to the _attribute property of the RRV, and reformatting for ease of reading.
<rule id="destination">
Fly me to
<one-of>
<item>London
<tag>
$._value="Arriving at Heathrow.";
$._attributes.code="EGLL";
$._attributes.time="UTC";
</tag>
</item>
<item>Paris
<tag>
$._value="Arriving at Orly.";
$._attributes.code="LFPO";
$._attributes.time="UTC+1";
</tag>
</item>
<item>Berlin
<tag>
$._value="Arriving at Tegel.";
$._attributes.code="EDDT";
$._attributes.time="UTC+1";
</tag>
</item>
</one-of>
</rule>
Using this grammar, the utterance, "Fly me to Paris," produces the following SML output:
<SML code="LFPO" time="UTC+1" confidence="0.840" text="Fly me to Paris" utteranceConfidence="0.840">
Arriving at Orly.
</SML>