RecognitionResult.TopConfidence 属性

获取 RecognitionResult 对象的 TopAlternate 属性的置信级别。

命名空间:  Microsoft.Ink
程序集:  Microsoft.Ink(在 Microsoft.Ink.dll 中)

语法

声明
Public ReadOnly Property TopConfidence As RecognitionConfidence
用法
Dim instance As RecognitionResult
Dim value As RecognitionConfidence

value = instance.TopConfidence
public RecognitionConfidence TopConfidence { get; }
public:
property RecognitionConfidence TopConfidence {
    RecognitionConfidence get ();
}
/** @property */
public RecognitionConfidence get_TopConfidence()
public function get TopConfidence () : RecognitionConfidence

属性值

类型:Microsoft.Ink.RecognitionConfidence
RecognitionResult 对象的 TopAlternate 属性的置信级别。

备注

在 Microsoft(R) 识别器 中,仅 Microsoft 英语 (US) 手写识别器和 Microsoft 笔势识别器支持置信级别。第三方识别器可能支持也可能不支持置信级别。

示例

此示例处理同步识别以响应用户操作(如单击菜单项或按钮)。首先,从 InkOverlay 对象的关联 Strokes 集合分配 RecognizerContext 对象的 Strokes 集合,并检查笔画计数。如果 Strokes 集合包含至少一个 Stroke 对象,则调用 Recognize 方法开始识别过程。如果识别成功,并且 TopConfidence(如果支持)不等于 RecognitionConfidencePoor(即为 IntermediateStrong),则将 TopString 添加到列表框中进行显示。

' assign strokes collection from the collected strokes
Me.mRecognizerContext.Strokes = Me.mInkOverlay.Ink.Strokes
' check stroke count. Recognize() will throw exception if no strokes
If (Me.mRecognizerContext.Strokes.Count > 0) Then
    Dim status As RecognitionStatus
    ' perform the recognition
    Dim rResult As RecognitionResult = Me.mRecognizerContext.Recognize(status)
    ' see if the recognizer used supports confidence levels
    Dim rSupportsConfidence As Boolean = RecognizerSupportsConfidence(mRecognizerContext.Recognizer)
    ' check status and TopConfidence (if supported)
    If (RecognitionStatus.NoError = status And _
        ((rSupportsConfidence And _
         rResult.TopConfidence <> RecognitionConfidence.Poor) Or _
         Not rSupportsConfidence)) Then
        listBoxRecognitionResults.Items.Add(rResult.TopString)
    End If
End If
// assign strokes collection from the collected strokes
this.mRecognizerContext.Strokes = this.mInkOverlay.Ink.Strokes;
// check stroke count. Recognize() will throw exception if no strokes
if (this.mRecognizerContext.Strokes.Count > 0)
{
    RecognitionStatus status;
    // perform the recognition
    RecognitionResult rResult = this.mRecognizerContext.Recognize(out status);
    // see if the recognizer used supports confidence levels
    bool rSupportsConfidence = RecognizerSupportsConfidence(mRecognizerContext.Recognizer);
    // check status and TopConfidence (if supported)
    if (RecognitionStatus.NoError == status &&
        ((rSupportsConfidence &&
         rResult.TopConfidence != RecognitionConfidence.Poor) ||
         !rSupportsConfidence))
    {
        listBoxRecognitionResults.Items.Add(rResult.TopString);
    }
}

下面的示例演示用于确定 Recognizer 是否支持置信级别的帮助器方法。

Private Function RecognizerSupportsConfidence(ByVal pRecognizer As Recognizer) As Boolean
    For Each G As Guid In pRecognizer.SupportedProperties
        If G = RecognitionProperty.ConfidenceLevel Then
            Return True
        End If
    Next
    Return False
End Function
private bool RecognizerSupportsConfidence(Recognizer pRecognizer)
{
    foreach (Guid G in pRecognizer.SupportedProperties)
    {
        if (G == RecognitionProperty.ConfidenceLevel)
        {
            return true;
        }
    }
    return false;
}

平台

Windows Vista

.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

RecognitionResult 类

RecognitionResult 成员

Microsoft.Ink 命名空间

RecognitionConfidence

RecognitionResult.TopAlternate