다음을 통해 공유


AnalysisStatusBase 클래스

업데이트: 2007년 11월

AnalysisStatus에 대한 기본 클래스입니다. 분석이 성공적으로 완료되었는지 여부 및 경고가 발생했는지 여부를 설명하여 분석 작업의 상태를 나타냅니다.

네임스페이스:  System.Windows.Ink.AnalysisCore
어셈블리:  IACore(IACore.dll)

구문

‘선언
Public Class AnalysisStatusBase
‘사용 방법
Dim instance As AnalysisStatusBase
public class AnalysisStatusBase
public ref class AnalysisStatusBase
public class AnalysisStatusBase
public class AnalysisStatusBase

예제

다음 예제에서는 잉크 분석 후 경고를 검색하는 방법을 보여 줍니다. 대개 설치되어 있지 않은 남아공 공용어 인식기를 사용하여 분석을 수행하면 분석이 InkRecognizerInitializationFailed 경고와 함께 실패한다는 것을 알 수 있습니다.

' Analyze using Afrikaans recognizer.
' You are unlikely to have this recognizer, so it will raise a warning.
Dim afrikaansAnalyzer As New InkAnalyzerBase()
Dim afrikaansLanguageId As Integer = 1078

' Accumulate the stroke data in collections.
Dim thePacketDescription() As Guid = theInkCollector.Ink.Strokes(0).PacketDescription
Dim theStrokeIdentifiers As ArrayList = New ArrayList()
Dim thePacketCounts As ArrayList = New ArrayList()
Dim thePacketData As ArrayList = New ArrayList()
Dim aStroke As Stroke
For Each aStroke In theInkCollector.Ink.Strokes
    ' Add the stroke data to the collections.
    theStrokeIdentifiers.Add(aStroke.Id)
    thePacketCounts.Add(aStroke.PacketCount)
    thePacketData.AddRange(aStroke.GetPacketData())
Next

' Add the stroke data to the base layer ink analyzer.
afrikaansAnalyzer.AddStrokes( _
        theStrokeIdentifiers.ToArray(GetType(Integer())), _
        thePacketCounts.ToArray(GetType(Integer())), _
        thePacketData.ToArray(GetType(Integer())), _
        thePacketDescription)

Dim status As AnalysisStatusBase = afrikaansAnalyzer.Analyze()

' Display any warnings
If status.Warnings.Count > 0 Then
    ' Initialize warning message
    Dim message As String = "Analysis resulted in the following warnings:" & Environment.NewLine

    ' Note: We should only expect to see the BackgroundException warning if
    ' we were performing background analysis.
    ' Loop through warnings
    Dim warning As AnalysisWarningBase
    For Each warning In status.Warnings
        Select Case warning.WarningCode
            Case System.Windows.Ink.AnalysisCore.AnalysisWarningCode.Aborted
                message = message & "Analysis operation was aborted. "
            Case System.Windows.Ink.AnalysisCore.AnalysisWarningCode.BackgroundException
                ' This is a fatal warning. Throw an exception.
                ' First, attempt to save as much document state as possible 
                ' ...

                ' Rethrow the exception so that it can be caught by an exception
                ' handler (or if there is no exception handler, a program error 
                ' debugger such as Dr. Watson can be invoked)
                Throw (warning.BackgroundException)
            Case System.Windows.Ink.AnalysisCore.AnalysisWarningCode.ConfirmedWithoutInkRecognition
                message = message & "Node was confirmed without ink recognition having been performed. "
            Case System.Windows.Ink.AnalysisCore.AnalysisWarningCode.ContextNodeLocationNotSet
                message = message & "Node does not have a proper location set. "
            Case System.Windows.Ink.AnalysisCore.AnalysisWarningCode.FactoidCoercionNotSupported
                message = message & "Factoid coercion failed "
                If (Not warning.AnalysisHint Is Nothing) AndAlso _
                    warning.AnalysisHint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.Factoid) Then
                    message = message & "for factoid: " & _
                        CType(warning.AnalysisHint.GetPropertyData( _
                              PropertyGuidsForAnalysisHintsBase.Factoid), String) & ". "
                End If
            Case System.Windows.Ink.AnalysisCore.AnalysisWarningCode.FactoidNotSupported

                If (Not warning.AnalysisHint Is Nothing) AndAlso _
                    warning.AnalysisHint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.Factoid) Then
                    message = message & _
                        CType(warning.AnalysisHint.GetPropertyData( _
                              PropertyGuidsForAnalysisHintsBase.Factoid), String) & _
                        " factoid was not respected. "
                End If
            Case System.Windows.Ink.AnalysisCore.AnalysisWarningCode.GuideNotSupported
                message = message & "Guide was not respected. "
            Case System.Windows.Ink.AnalysisCore.AnalysisWarningCode.AddInkToRecognizerFailed
                message = message & "Ink could not be added to the InkRecognizer. "
            Case System.Windows.Ink.AnalysisCore.AnalysisWarningCode.InkRecognizerInitializationFailed
                message = message & "The InkRecognizer failed to initialize. "
            Case System.Windows.Ink.AnalysisCore.AnalysisWarningCode.NoMatchingInkRecognizerFound
                message = message & "There are no ink recognizers meeting the language or capabilities needed. "
            Case System.Windows.Ink.AnalysisCore.AnalysisWarningCode.LanguageIdNotRespected
                message = message & "The language ID set on a stroke did not match the language ID of the InkRecognizer. "
            Case System.Windows.Ink.AnalysisCore.AnalysisWarningCode.PartialDictionaryTermsNotSupported
                message = message & "Partial dictionary terms could not be returned from the text recognizer. "
            Case System.Windows.Ink.AnalysisCore.AnalysisWarningCode.SetPrefixSuffixFailed
                message = message & "The text recognizer was unable to respect either the prefix or suffix. "
                If (Not warning.AnalysisHint Is Nothing) AndAlso _
                    warning.AnalysisHint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.PrefixText) Then
                    message = message & "Prefix: " & _
                        warning.AnalysisHint.GetPropertyData(PropertyGuidsForAnalysisHintsBase.PrefixText) _
                        & ". "
                End If
                If (Not warning.AnalysisHint Is Nothing) AndAlso _
                    warning.AnalysisHint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.SuffixText) Then
                    message = message & "Suffix: " & _
                        warning.AnalysisHint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.SuffixText) _
                        & ". "
                End If
            Case System.Windows.Ink.AnalysisCore.AnalysisWarningCode.WordlistNotSupported
                message = message & "Wordlist was not respected. "
            Case System.Windows.Ink.AnalysisCore.AnalysisWarningCode.WordModeNotSupported
                message = message & "Word mode was not respected. "
        End Select


        ' Add node id information
        Dim id As Guid
        For Each id In warning.GetNodeIds()
            message = message & "Id: " & id.ToString() & " "
        Next id


        ' Add hint information
        If Not (warning.AnalysisHint Is Nothing) Then

            Dim hint As ContextNodeBase = warning.AnalysisHint
            message = message & Environment.NewLine & "Hint information: "
            message = message & "AllowPartialDictionaryTerms"
            If hint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.AllowPartialDictionaryTerms) Then
                message = message & " = " & _
                    hint.GetPropertyData( _
                        PropertyGuidsForAnalysisHintsBase.AllowPartialDictionaryTerms).ToString()
            Else
                message = message & " = False "
            End If
            message = message & "CoerceToFactoid"
            If hint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.CoerceToFactoid) Then
                message = message & " = " & _
                    hint.GetPropertyData( _
                        PropertyGuidsForAnalysisHintsBase.CoerceToFactoid).ToString()
            Else
                message = message & " = False "
            End If
            If hint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.Factoid) Then
                message = message & "Factoid = " & _
                    warning.AnalysisHint.GetPropertyData(PropertyGuidsForAnalysisHintsBase.Factoid) & " "
            End If
            If hint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.Guide) Then
                Dim theInkRecognizerGuideBase As InkRecognizerGuideBase = _
                    CType(hint.GetPropertyData(PropertyGuidsForAnalysisHintsBase.Guide), _
                          InkRecognizerGuideBase)

                message += "Guide Drawn Box = {" & theInkRecognizerGuideBase.DrawnBoxLeft.ToString() _
                                              & ", " & theInkRecognizerGuideBase.DrawnBoxTop.ToString() _
                                              & ", " & theInkRecognizerGuideBase.DrawnBoxRight.ToString() _
                                              & ", " & theInkRecognizerGuideBase.DrawnBoxBottom.ToString() _
                                              & ")"

                message &= "Guide Writing Box = {" & theInkRecognizerGuideBase.WritingBoxLeft.ToString() _
                                                & ", " & theInkRecognizerGuideBase.WritingBoxTop.ToString() _
                                                & ", " & theInkRecognizerGuideBase.WritingBoxRight.ToString() _
                                                & ", " & theInkRecognizerGuideBase.WritingBoxBottom.ToString() _
                                                & ")"

                message = message & String.Format("Guide = ({0}, {1})", _
                     theInkRecognizerGuideBase.Columns, theInkRecognizerGuideBase.Rows)

            End If

            If hint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.Name) Then
                message = message & "Name = " & _
                    CType(warning.AnalysisHint.GetPropertyData(PropertyGuidsForAnalysisHintsBase.Name), String) _
                    & " "
            End If

            If Not hint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.PrefixText) Then
                message = message & "PrefixText = " & _
                    CType(warning.AnalysisHint.GetPropertyData(PropertyGuidsForAnalysisHintsBase.PrefixText), String) _
                    & " "
            End If

            If Not hint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.SuffixText) Then
                message = message & "SuffixText = " & _
                    CType(warning.AnalysisHint.GetPropertyData(PropertyGuidsForAnalysisHintsBase.SuffixText), String) _
                    & " "
            End If

            message = message & "WordMode"
            If hint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.WordMode) Then
                message = message & " = " & _
                    CType(hint.GetPropertyData(PropertyGuidsForAnalysisHintsBase.WordMode), String)
            Else
                message = message & " = False"
            End If
        End If

        message = message & Environment.NewLine
    Next warning

    ' Show in the output window
    System.Diagnostics.Debug.WriteLine(message)
End If
If status.Successful Then
    Me.labelResult.Text = afrikaansAnalyzer.GetRecognizedString()
End If

            // Analyze using Afrikaans recognizer.
            // You are unlikely to have this recognizer, so it will raise a warning.
            InkAnalyzerBase afrikaansInkAnalyzer = new InkAnalyzerBase();
            int afrikaansLanguageId = 1078;


            // Accumulate the stroke data in collections.
            Guid[] thePacketDescription = theInkCollector.Ink.Strokes[0].PacketDescription;
            ArrayList theStrokeIdentifiers = new ArrayList();
            ArrayList thePacketCounts = new ArrayList();
            ArrayList thePacketData = new ArrayList();
            foreach (Stroke aStroke in theInkCollector.Ink.Strokes)
            {
                // Add the stroke data to the collections.
                theStrokeIdentifiers.Add(aStroke.Id);
                thePacketCounts.Add(aStroke.PacketCount);
                thePacketData.AddRange(aStroke.GetPacketData());
            }

            // Add the stroke data to the base layer ink analyzer.
            afrikaansInkAnalyzer.AddStrokes(
                theStrokeIdentifiers.ToArray(typeof(int)) as int[],
                thePacketCounts.ToArray(typeof(int)) as int[],
                thePacketData.ToArray(typeof(int)) as int[],
                thePacketDescription);

            AnalysisStatusBase status = afrikaansInkAnalyzer.Analyze();

            // Note: We should only expect to see the BackgroundException warning if
            // we were performing background analysis.
            // Display any warnings
            if (!status.Successful)
            {
                // Initialize warning message
                string message = "Analysis resulted in the following warnings:" + Environment.NewLine;

                // Loop through warnings
                foreach (AnalysisWarningBase warning in status.Warnings)
                {
                    switch (warning.WarningCode)
                    {
                        case System.Windows.Ink.AnalysisCore.AnalysisWarningCode.Aborted:
                            message += "Analysis operation was aborted. ";
                            break;
                        case System.Windows.Ink.AnalysisCore.AnalysisWarningCode.BackgroundException:
                            // This is a fatal warning. Throw an exception.
                            // First, attempt to save as much doc state as possible 
                            // ...

                            // Rethrow the exception so that it can be caught by an exception
                            // handler (or if there is no exception handler, a program error 
                            // debugger such as Dr. Watson can be invoked)
                            throw(warning.BackgroundException);
                        case System.Windows.Ink.AnalysisCore.AnalysisWarningCode.ConfirmedWithoutInkRecognition:
                            message += "Node was confirmed without ink recognition having been performed. ";
                            break;
                        case System.Windows.Ink.AnalysisCore.AnalysisWarningCode.ContextNodeLocationNotSet:
                            message += "Node does not have a proper location set. ";
                            break;
                        case System.Windows.Ink.AnalysisCore.AnalysisWarningCode.FactoidCoercionNotSupported:
                            message += "Factoid coercion failed ";
                            if (warning.AnalysisHint != null && 
                                warning.AnalysisHint.ContainsPropertyData(
                                        PropertyGuidsForAnalysisHintsBase.Factoid))
                            {
                                message += "for factoid: " + 
                                    (string) warning.AnalysisHint.GetPropertyData(
                                        PropertyGuidsForAnalysisHintsBase.Factoid) + ". ";
                            } 
                            break;
                        case System.Windows.Ink.AnalysisCore.AnalysisWarningCode.FactoidNotSupported:
                            if (warning.AnalysisHint != null &&
                                warning.AnalysisHint.ContainsPropertyData(
                                        PropertyGuidsForAnalysisHintsBase.Factoid))
                            {
                                message +=
                                    (string)warning.AnalysisHint.GetPropertyData(
                                        PropertyGuidsForAnalysisHintsBase.Factoid) 
                                     + " factoid was not respected. ";
                            }
                            break;
                        case System.Windows.Ink.AnalysisCore.AnalysisWarningCode.GuideNotSupported:
                            message += "Guide was not respected. ";
                            break;
                        case System.Windows.Ink.AnalysisCore.AnalysisWarningCode.AddInkToRecognizerFailed:
                            message += "Ink could not be added to the InkRecognizer. ";
                            break;
                        case System.Windows.Ink.AnalysisCore.AnalysisWarningCode.InkRecognizerInitializationFailed:
                            message += "The InkRecognizer failed to initialize. ";
                            break;
                        case System.Windows.Ink.AnalysisCore.AnalysisWarningCode.NoMatchingInkRecognizerFound:
                            message += "There are no ink recognizers meeting the language or capabilities needed. ";
                            break;
                        case System.Windows.Ink.AnalysisCore.AnalysisWarningCode.LanguageIdNotRespected:
                            message += "The language ID set on a stroke did not match the language ID of the InkRecognizer. ";
                            break;
                        case System.Windows.Ink.AnalysisCore.AnalysisWarningCode.PartialDictionaryTermsNotSupported:
                            message += "Partial dictionary terms could not be returned from the text recognizer. ";
                            break;
                        case System.Windows.Ink.AnalysisCore.AnalysisWarningCode.SetPrefixSuffixFailed:
                            message += "The text recognizer was unable to respect either the prefix or suffix. ";
                            if (warning.AnalysisHint != null && 
                                warning.AnalysisHint.ContainsPropertyData(
                                    PropertyGuidsForAnalysisHintsBase.PrefixText))
                            {
                                message += "Prefix: " + 
                                    warning.AnalysisHint.GetPropertyData(
                                        PropertyGuidsForAnalysisHintsBase.PrefixText) + ". ";
                            }
                            if (warning.AnalysisHint != null &&
                                warning.AnalysisHint.ContainsPropertyData(
                                    PropertyGuidsForAnalysisHintsBase.SuffixText))
                            {
                                message += "Suffix: " +
                                    warning.AnalysisHint.GetPropertyData(
                                        PropertyGuidsForAnalysisHintsBase.SuffixText) + ". ";
                            }
                            break;
                        case System.Windows.Ink.AnalysisCore.AnalysisWarningCode.WordlistNotSupported:
                            message += "Wordlist was not respected. ";
                            break;
                        case System.Windows.Ink.AnalysisCore.AnalysisWarningCode.WordModeNotSupported:
                            message += "Word mode was not respected. ";
                            break;
                    }

                    // Add node id information
                    foreach (Guid id in warning.GetNodeIds())
                        message += "Id: " + id.ToString() + " ";

                    // Add hint information
                    if (warning.AnalysisHint != null)
                    {
                        ContextNodeBase  hint = warning.AnalysisHint;
                        message += Environment.NewLine + "Hint information: ";
                        message += "AllowPartialDictionaryTerms";

                        if (hint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.AllowPartialDictionaryTerms))
                            message += " = " +
                                ((bool)hint.GetPropertyData(
                                    PropertyGuidsForAnalysisHintsBase.AllowPartialDictionaryTerms)).ToString();
                        else
                            message += " = false ";

                        message += "CoerceToFactoid";
                        if (hint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.CoerceToFactoid))
                            message += " = " +
                                ((bool)hint.GetPropertyData(
                                    PropertyGuidsForAnalysisHintsBase.CoerceToFactoid)).ToString();
                        else
                            message += " = false ";

                        if (hint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.Factoid))
                            message += "Factoid = " + 
                                (string) warning.AnalysisHint.GetPropertyData(
                                PropertyGuidsForAnalysisHintsBase.Factoid) + " ";

                        if (hint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.Guide))
                        {
                            InkRecognizerGuideBase theInkRecognizerGuideBase = 
                                (InkRecognizerGuideBase) hint.GetPropertyData(
                                PropertyGuidsForAnalysisHintsBase.Guide);

                            message += "Guide Drawn Box = {" + theInkRecognizerGuideBase.DrawnBoxLeft.ToString()
                                                      + ", " + theInkRecognizerGuideBase.DrawnBoxTop.ToString()
                                                      + ", " + theInkRecognizerGuideBase.DrawnBoxRight.ToString()
                                                      + ", " + theInkRecognizerGuideBase.DrawnBoxBottom.ToString() 
                                                      + ")";

                            message += "Guide Writing Box = {" + theInkRecognizerGuideBase.WritingBoxLeft.ToString()
                                                        + ", " + theInkRecognizerGuideBase.WritingBoxTop.ToString()
                                                        + ", " + theInkRecognizerGuideBase.WritingBoxRight.ToString()
                                                        + ", " + theInkRecognizerGuideBase.WritingBoxBottom.ToString()
                                                        + ")";  

                        }
                        if (hint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.Name))
                            message += "Name = " +
                                (string) warning.AnalysisHint.GetPropertyData(
                                    PropertyGuidsForAnalysisHintsBase.Name);

                        if (hint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.PrefixText))
                            message += "PrefixText = " + 
                                (string) warning.AnalysisHint.GetPropertyData(
                                    PropertyGuidsForAnalysisHintsBase.PrefixText) + " ";
                        if (hint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.SuffixText))
                            message += "SuffixText = " + 
                                (string) warning.AnalysisHint.GetPropertyData(
                                    PropertyGuidsForAnalysisHintsBase.SuffixText) + " ";
                        message += "WordMode";

                        if (hint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.WordMode))
                            message += " = " +
                                ((bool) hint.GetPropertyData(
                                    PropertyGuidsForAnalysisHintsBase.WordMode)).ToString();
                        else
                            message += " = false";
                    }
                    message += Environment.NewLine;
                }

                // Show in the output window
                System.Diagnostics.Debug.WriteLine(message);
            }

            if (status.Successful)
            {
                this.resultsLabel.Text = afrikaansInkAnalyzer.GetRecognizedString();
            }

상속 계층 구조

System.Object
  System.Windows.Ink.AnalysisCore.AnalysisStatusBase

스레드로부터의 안전성

이 형식의 모든 공용 static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

플랫폼

Windows Vista, Windows XP SP2, Windows Server 2003

.NET Framework 및 .NET Compact Framework에서 모든 플랫폼의 전체 버전을 지원하지는 않습니다. 지원되는 버전의 목록을 보려면 .NET Framework 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

3.0에서 지원

참고 항목

참조

AnalysisStatusBase 멤버

System.Windows.Ink.AnalysisCore 네임스페이스

AnalysisStatus