SemanticValue.Confidence Property

 

Returns a relative measure of the certainty as to the correctness of the semantic parsing that returned the current instance of SemanticValue.

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

public float Confidence { get; }

Property Value

Type: System.Single

Returns a float that is a relative measure of the certainty of semantic parsing that returned the current instance of SemanticValue.

The SemanticValue.Confidence property, which returns a measure of the correctness of semantic parsing, should not be confused with the RecognizedPhrase.Confidence property, which returns a measure of the accuracy of speech recognition.

The following example is used to recursively traverse and then display information (including confidence) as a TreeNodeCollection, or as the nodes making up the tree structure of the semantics used to recognize a phrase.

internal static void CreateSemanticsTreeNodes(
        TreeNodeCollection nodes,
        SemanticValue semantics,
        String name) 
{
  string semanticsText = 
      String.Format("  {0}  (Confidence {1})", name,semantics.Confidence);

  // Format integers as hexadecimal.
  if (semantics.Value == null )
  {
    semanticsText = semanticsText + " = null";
  }
  else 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);
  foreach (KeyValuePair<String, SemanticValue> child in semantics) 
  {
    CreateSemanticsTreeNodes(semanticsNode.Nodes, child.Value, child.Key);
  }
  nodes.Add(semanticsNode);
}

.NET Framework
Available since 3.0
Return to top
Show: