Поделиться через


RecognitionResult.TopConfidence - свойство

Обновлен: Ноябрь 2007

Gets the confidence level of the TopAlternate property of the RecognitionResult object.

Пространство имен:  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
The confidence level of the TopAlternate property of the RecognitionResult object.

Заметки

Of the Microsoft® recognizer, only the Microsoft English (US) Handwriting Recognizer and the Microsoft Gesture Recognizer support confidence levels. Third party recognizers may or may not support confidence levels.

Примеры

In this example, synchronous recognition is handled in response to a user action such as clicking on a menu item or a button. First, the Strokes collection of a RecognizerContext object is assigned from the Strokes collection associated with an InkOverlay object, and checked for stroke count. If the Strokes collection contains at least one Stroke object, the recognition process begins with a call to the Recognize method. If recognition is successful and the TopConfidence (if supported) does not equal RecognitionConfidencePoor (i.e. it is Intermediate or Strong), the TopString is displayed by adding it to a list box.

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

The following example shows the helper method used to determine if the Recognizer supports confidence levels.

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