RecognizedPhrase.Semantics Property

Returns the any of semantic logic of a Grammar that was used to return a RecognizedPhrase.

Namespace: Microsoft.Speech.Recognition
Assembly: Microsoft.Speech (in microsoft.speech.dll)

Syntax

'Declaration

Property Value

Returns an instance of SemanticValue specifying what, if any, semantic logic was used by the recognition engine to produce the current RecognizedPhrase.

Example

The example below shows how an application might use recursion to display the SemanticValue returned by Semantics on a TreeView object.

// Recursively creates the semantics tree based on the result.
internal static void DisplaySemanticsTreeView(TreeView treeView, RecognizedPhrase result) {
    if (treeView != null & result != null) {
        CreateSemanticsTreeNodes(treeView.Nodes, result.Semantics, "root");
        treeView.ExpandAll();
    }

}
// Recursively creates the nodes to the semanticsTreeView.
internal static void CreateSemanticsTreeNodes(TreeNodeCollection nodes, SemanticValue semantics,
                                     String name) {
    if (semantics != null && semantics.Confidence == 1.0 && result.Semantics.Count != 0) {
        string semanticsText = String.Format("  {0} (  {1})", name, semantics.Confidence);

        if (semantics.Value != null) {
            if (semantics.Value.GetType() == typeof(int)) {
                semanticsText = String.Format("{0} = {1:X} ", semanticsText, semantics.Value);
            } else {
                semanticsText = semanticsText + " = " + semantics.Value.ToString();
            }
        }
        TreeNode semanticsNode = new TreeNode(semanticsText);
       // recursively work down through semantic tree.
        foreach (KeyValuePair<String, SemanticValue> child in semantics) {
            Utils.CreateSemanticsTreeNodes(semanticsNode.Nodes, child.Value, child.Key);
        }

        nodes.Add(semanticsNode);
    }
}

Thread Safety

All public static (Shared in Visual Basic) members of this type are thread-safe. Instance members are not guaranteed to be thread-safe.

Platforms

Development Platforms

Windows XP Professional with Service Pack 2 (SP2), Windows Server 2003, Windows Vista Ultimate Edition, Windows Vista Business Edition, Windows Vista Enterprise Edition

Target Platforms

See Also

Reference

RecognizedPhrase Class
RecognizedPhrase Members
Microsoft.Speech.Recognition Namespace