次の方法で共有


RecognizerContext.WordList プロパティ

認識結果を向上させるために使用される 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 プロパティに割り当てて、プロパティを初期化する必要があります。

WordList プロパティの設定が成功するのは、Strokes プロパティが nullnull 参照 (Visual Basic では Nothing) の場合のみです。WordList プロパティを設定してから、Strokes コレクションを RecognizerContextStrokes プロパティに結び付けるか、Strokes プロパティを nullnull 参照 (Visual Basic では Nothing) に設定してから、WordList プロパティを設定する必要があります。

ms572024.alert_note(ja-jp,VS.90).gifメモ :

後者の方法を使用する場合は、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 例外 "The method was called after Process has been called or Factoid has been set" が発生します。

文字列が単語リストに追加される場合、その大文字の文字列も暗黙に追加されます。たとえば、"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