다음을 통해 공유


RecognizerContext.WordList 속성

업데이트: 2007년 11월

인식 결과를 개선하는 데 사용되는 WordList 개체를 가져오거나 설정합니다.

네임스페이스:  Microsoft.Ink
어셈블리:  Microsoft.Ink(Microsoft.Ink.dll)

구문

‘선언
Public Property WordList As WordList
‘사용 방법
Dim instance As RecognizerContext
Dim value As WordList

value = instance.WordList

instance.WordList = value
public WordList WordList { get; set; }
public:
property WordList^ WordList {
    WordList^ get ();
    void set (WordList^ value);
}
/** @property */
public WordList get_WordList()
/** @property */
public  void set_WordList(WordList value)
public function get WordList () : WordList
public function set WordList (value : WordList)

속성 값

형식: Microsoft.Ink.WordList
인식 결과를 개선하는 데 사용되는 단어 목록입니다. 반환되는 개체는 직접 참조가 아니라 기본 단어 목록의 내부 작업 복사본입니다.

설명

이 속성을 사용하려면 newWordList 개체를 인스턴스화하고 새로 만든 개체를 WordList 속성에 할당하여 속성을 초기화해야 합니다.

Strokes 속성이 nullNull 참조(Visual Basic의 경우 Nothing)인 경우에만 WordList 속성을 설정할 수 있습니다. Strokes 컬렉션을 RecognizerContextStrokes 속성에 연결하기 전에 WordList 속성을 설정하거나, Strokes 속성을 nullNull 참조(Visual Basic의 경우 Nothing)로 설정한 후에 WordList 속성을 설정해야 합니다.

참고

두 번째 메서드를 사용하는 경우 Strokes 컬렉션을 RecognizerContext 개체의 Strokes 속성에 다시 연결해야 할 수 있습니다.

현재 단어 목록을 제거하고 사용자 사전을 사용하려면 WordList 속성을 nullNull 참조(Visual Basic의 경우 Nothing)로 설정합니다. 이후에 WordList 개체를 수정해도 인식 결과가 수정되지는 않습니다.

그러므로 이 속성이 nullNull 참조(Visual Basic의 경우 Nothing)로 설정되었는지를 확인하는 테스트는 아무런 의미가 없습니다. get 접근자가 반환하는 값은 항상 null이 아닙니다. 다음은 이에 대한 샘플입니다.

Dim RC As RecognizerContext = New RecognizerContext()
RC.WordList = Nothing
If (Not RC.WordList Is Nothing) Then ' always true
    ' but this won't work, throws a null reference exception
    RC.WordList.Add("thunk")
End If
RecognizerContext RC = new RecognizerContext();
RC.WordList = null;
if (RC.WordList != null) // always true
{
    // but this won't work, throws a null reference exception
    RC.WordList.Add("thunk");
}

이 속성의 반환 값은 직접 참조가 아닌 기본 단어 목록의 내부 작업 복사본이므로 WordList 속성이 다시 할당되기 전까지는 사용자가 추가하는 단어나 구를 인식 중에 사용할 수 없습니다. 다음을 살펴보십시오.

Dim RC As RecognizerContext = New RecognizerContext()
RC.WordList = New WordList()
Dim testStr As String = "thunk"
' test if string is supported - false
Dim isTestStrSupported As Boolean = RC.IsStringSupported(testStr)
' get a copy of the WordList
Dim WL As WordList = RC.WordList
' add the string to the copy
WL.Add(testStr)
' test if string is supported - still false
isTestStrSupported = RC.IsStringSupported(testStr)
' assign copy back to the WordList property
RC.WordList = WL
' test if string is supported - now true
isTestStrSupported = RC.IsStringSupported(testStr)
RecognizerContext RC = new RecognizerContext();
RC.WordList = new WordList();
string testStr = "thunk";
// test if string is supported - false
bool isTestStrSupported = RC.IsStringSupported(testStr);
// get a copy of the WordList
WordList WL = RC.WordList;
// add the string to the copy
WL.Add(testStr);
// test if string is supported - still false
isTestStrSupported = RC.IsStringSupported(testStr);
// assign copy back to the WordList property
RC.WordList = WL;
// test if string is supported - now true
isTestStrSupported = RC.IsStringSupported(testStr);

이전 예제에서는 테스트 단어가 WordList 속성의 내부 복사본에 추가되며, 그런 후에 해당 복사본이 WordList 속성에 다시 할당됩니다.

테스트 단어를 WordList 속성 자체에 추가할 수도 있습니다. 이렇게 하는 경우에도 내부 작업 복사본이 변경되므로 새로 추가한 단어가 인식 중에 사용할 수 있는 상태가 되기 전에 WordList 속성을 다시 할당해야 합니다.

Dim RC As RecognizerContext = New RecognizerContext()
RC.WordList = New WordList()
Dim testStr As String = "thunk"
' test if string is supported - false
Dim isTestStrSupported As Boolean = RC.IsStringSupported(testStr)
' get a copy of the WordList
Dim WL As WordList = RC.WordList
' add the string to the WordList property itself
RC.WordList.Add(testStr)
' test if string is supported - still false
isTestStrSupported = RC.IsStringSupported(testStr)
' assign copy back to the WordList property
RC.WordList = WL
' test if string is supported - now true
isTestStrSupported = RC.IsStringSupported(testStr)
RecognizerContext RC = new RecognizerContext();
RC.WordList = new WordList();
string testStr = "thunk";
// test if string is supported - false
bool isTestStrSupported = RC.IsStringSupported(testStr);
// get a copy of the WordList
WordList WL = RC.WordList;
// add the string to the WordList property itself
RC.WordList.Add(testStr);
// test if string is supported - still false
isTestStrSupported = RC.IsStringSupported(testStr);
// assign copy back to the WordList property
RC.WordList = WL;
// test if string is supported - now true
isTestStrSupported = RC.IsStringSupported(testStr);

WordList 속성의 get 접근자를 통해 가져온 복사본을 해당 속성에 다시 할당하는 경우 원래 WordList는 수정된 콘텐츠로 바뀌지 않습니다. 대신 원래 WordList에 델타가 추가됩니다. 원본 WordList를 바꾸려는 경우에는 다음 방법 중 하나를 사용하십시오.

  1. RecognizerContext 개체를 만들어 수정된 WordList를 할당합니다.

  2. WordList 개체를 만들어 기존 RecognizerContext에 할당합니다.

Factoid 속성을 사용하여 검색을 컨텍스트와 연결된 단어 목록으로 제한합니다. 보다 관련성 높은 결과가 반환되도록 하려면 RecognitionFlags 속성을 설정해야 할 수도 있습니다.

유의 사실을 설정한 후에는 WordList 속성을 설정할 수 없습니다. 그러면 유의 사실이 존재하지 않을 수도 있는 단어 목록을 참조하지 않습니다. 유의 사실이 존재하지 않는 단어 목록을 참조하려고 하면 "프로세스를 호출하거나 유의 사실을 설정한 후에 메서드를 호출했습니다."라는 COM 예외가 발생합니다.

단어 목록에 문자열을 추가하면 대문자 버전도 암시적으로 추가됩니다. 예를 들어 "hello"를 추가하면 "Hello" 및 "HELLO"가 암시적으로 추가됩니다.

WordList를 지우려면 빈 WordList 개체와 같게 설정하십시오.

예제

이 예제에서는 RecognizerContext 개체가 인스턴스화되고 새 WordList 개체가 해당 WordList 속성에 할당됩니다. 그런 다음 IsStringSupported 메서드를 사용하여 지정한 문자열이 지원되는지 여부가 확인됩니다. 지원되지 않는 경우 해당 문자열은 WordList에 추가됩니다.

Dim RC As RecognizerContext = New RecognizerContext()
RC.WordList = New WordList()
Dim testStr As String = "thunk"
If Not RC.IsStringSupported(testStr) Then
    Dim WL As WordList = RC.WordList
    WL.Add(testStr)
    ' testStr is not available for use in recognition
    ' until the WordList property is re-assigned
    RC.WordList = WL
End If
RecognizerContext RC = new RecognizerContext();
RC.WordList = new WordList();
string testStr = "thunk";
if (!RC.IsStringSupported(testStr))
{
    WordList WL = RC.WordList;
    WL.Add(testStr);
    // testStr is not available for use in recognition
    // until the WordList property is re-assigned
    RC.WordList = WL;
}

플랫폼

Windows Vista

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

버전 정보

.NET Framework

3.0에서 지원

참고 항목

참조

RecognizerContext 클래스

RecognizerContext 멤버

Microsoft.Ink 네임스페이스

RecognizerContext

WordList

RecognizerContext.Strokes

RecognizerContext.Factoid

RecognizerContext.RecognitionFlags