This documentation is archived and is not being maintained.

RecognizedPhrase.Semantics Property

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

Namespace: System.Speech.Recognition
Assembly: System.Speech (in system.speech.dll)

public SemanticValue Semantics { get; }
/** @property */
public SemanticValue get_Semantics ()

public function get Semantics () : SemanticValue

Not applicable.

Property Value

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

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);
    }
}

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0
Show: