Share via


Serialization of Developer-defined Rule Variable Properties

  Microsoft Speech Technologies Homepage

By default, the semantic interpreter returns developer-defined properties of the Rule Variable as daughter nodes, where the element name for the node is the name of the property. If the script expression assigns a simple value to the property, the semantic interpreter returns the daughter node with its assigned value and a confidence value. In the following example, the script assigns the simple string value Orly to the Airport property:

<rule id="destination">
    Fly me to
    <one-of>
      <item>London<tag>$.Airport="Heathrow";</tag></item>
      <item>Paris<tag>$.Airport="Orly";</tag></item>
      <item>Berlin<tag>$.Airport="Tegel";</tag></item>
    </one-of>
</rule>

Using this grammar, the utterance, "Fly me to Paris," produces the following SML output:

<SML confidence="0.840" text="Fly me to Paris" utteranceConfidence="0.840">
    <Airport confidence="0.840">Orly</Airport>
</SML>

Initializing Properties as Objects

If a script expression initializes a property of a Rule Variable as an object, the semantic interpreter returns a daughter node with a confidence attribute and the value of the object. If the object is empty, the interpreter returns an empty daughter node. The following grammar is identical to the previous grammar except that instead of assigning a simple scalar value to the Airport property, the expressions create Airport as an empty object.

<rule id="destination">
    Fly me to
    <one-of>
      <item>London<tag>$.Airport={};</tag></item>
      <item>Paris<tag>$.Airport={};</tag></item>
      <item>Berlin<tag>$.Airport={};</tag></item>
    </one-of>
</rule>

Using this grammar, the utterance, "Fly me to Paris," produces the following SML output:

<SML confidence="0.840" text="Fly me to Paris" utteranceConfidence="0.840">
    <Airport confidence="0.840" />
</SML>

Initializing a Property as an Array

If the property of the Rule Variable is an array, the interpreter returns a daughter node with the name of the property and a confidence value. However, the daughter node contains no text content. Instead, the daughter node contains child elements with the name "item." The following grammar creates a DepartingAt property as an array having two members.

<rule id="destination">
    Fly me to
    <one-of>
      <item>London<tag>$.DepartingAt=["10:00", "13:00"];</tag></item>
      <item>Paris<tag>$.DepartingAt=["12:45", "16:15"];</tag></item>
      <item>Berlin<tag>$.DepartingAt=["09:00", "14:10"];</tag></item>
    </one-of>
</rule>

Using this grammar, the utterance, "Fly me to Paris," produces the following SML output:

<SML confidence="0.779" text="Fly me to Paris" utteranceConfidence="0.779">
    <DepartingAt confidence="0.779">
        <item>12:45</item>
        <item>16:15</item>
    </DepartingAt>
</SML>

Returning Text Content in a Property Node

The text content contained in an SML node can be a simple type value only. In order to return an SML node that contains both a daughter node and text content in the daughter node, the script expression must initialize a property of the Rule Variable as an object, and assign the value to be returned as text content to the _value property of the object. The following grammar illustrates this concept.

<rule id="destination">
    <tag>$.Airport={};</tag>
    Fly me to
    <one-of>
      <item>London<tag>$.Airport._value="We fly to Heathrow airport.";</tag></item>
      <item>Paris<tag>$.Airport._value="We fly to Orly airport.";</tag></item>
      <item>Berlin<tag>$.Airport._value="We fly to Tegel airport.";</tag></item>
    </one-of>
</rule>

Using this grammar, the utterance, "Fly me to Paris," produces the following SML output:

<SML confidence="0.840" text="Fly me to Paris" utteranceConfidence="0.840">
    <Airport confidence="0.840">We fly to Orly airport.</Airport>
</SML>

Creating New Attributes for a Property Node

Use the _attributes property to add new developer-defined attributes to the nodes that are created by developer-defined properties. The following grammar is identical to the previous grammar expect for the addition of script expressions that create new attributes in the Airport node of the SML output.

<rule id="destination">
    <tag>$.Airport={};</tag>
    Fly me to
    <one-of>
      <item>London
        <tag>
          $.Airport._value="We fly to Heathrow airport.";
          $.Airport._attributes.country="UK";
          $.Airport._attributes.code="EGLL";
          $.Airport._attributes.elevation="80 ft. MSL";
        </tag>
      </item>
      <item>Paris
        <tag>
          $.Airport._value="We fly to Orly airport.";
          $.Airport._attributes.country="FR";
          $.Airport._attributes.code="LFPO";
          $.Airport._attributes.elevation="292 ft. MSL";
        </tag>
      </item>
      <item>Berlin
        <tag>
          $.Airport._value="We fly to Tegel airport.";
          $.Airport._attributes.country="DEU";
          $.Airport._attributes.code="EDDT";
          $.Airport._attributes.elevation="121 ft. MSL";
        </tag>
      </item>
    </one-of>
</rule>

Using this grammar, the utterance, "Fly me to Paris," produces the following SML output:

<SML confidence="0.779" text="Fly me to Paris" utteranceConfidence="0.779">
  <Airport confidence="0.779" country="FR" code="LFPO" elevation="292 ft. MSL">We fly to Orly airport.</Airport> 
</SML>

Defining Multiple Properties

The following grammar demonstrates using script expressions to create multiple developer-defined properties of the different types discussed throughout this document, as well as a _value property for 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="List of departures."; $.Airport={};</tag>
    Fly me to
    <one-of>
      <item>London<tag>
                       $.DepartingAt=["10:00", "13:00"];
                       $.Airport._value="We fly to Heathrow airport.";
                       $.Airport._attributes.country="UK";
                       $.Airport._attributes.code="EGLL";
                       $.Airport._attributes.elevation="80 ft. MSL";
                  </tag>
      </item>
      <item>Paris<tag>
                      $.DepartingAt=["12:45", "16:15"];
                      $.Airport._value="We fly to Orly airport.";
                      $.Airport._attributes.country="FR";
                      $.Airport._attributes.code="LFPO";
                      $.Airport._attributes.elevation="292 ft. MSL";
                 </tag>
      </item>
      <item>Berlin<tag>
                       $.DepartingAt=["09:00", "14:10"];
                       $.Airport._value="We fly to Tegel airport.";
                       $.Airport._attributes.country="DEU";
                       $.Airport._attributes.code="EDDT";
                       $.Airport._attributes.elevation="121 ft. MSL";
                  </tag>
      </item>
    </one-of>
</rule>

</grammar>

Using this grammar, the utterance, "Fly me to Paris," produces the following SML output:

<SML confidence="0.805" text="Fly me to Paris" utteranceConfidence="0.805">
  List of departures. 
  <Airport confidence="0.805" country="FR" code="LFPO" elevation="292 ft. MSL">
    We fly to Orly airport.
  </Airport> 
    <DepartingAt confidence="0.805">
      <item>12:45</item> 
      <item>16:15</item> 
    </DepartingAt>
</SML>