Using Application Dictionaries with the Tablet PC Platform APIs
Using Application Dictionaries with the Tablet PC Platform APIs |
Introduction to using application dictionaries with the Microsoft® Windows® XP Tablet PC Edition Platform application programming interfaces (APIs).
To use an application dictionary with the Tablet PC Platform APIs, you must first create a file with the list of words for your application dictionary.
The easiest solution for this is to use a text file that contains a list of the words. When your application loads, it reads the text file and creates a WordList object from the list of words in the file. For each recognizer context associated with the application dictionary, set the WordList property of the RecognizerContext object to the word list in the text file.
The following example illustrates how to create a WordList object from a StringCollection collection. This example assumes that you have already loaded the list of words from disk and created a StringCollection collection from these words.
[C#]
using System.Collections.Specialized;
using Microsoft.Ink;
//...
RecognizerContext theRecognizerContext;
StringCollection theUserDictionary;
//...
// Initialize theRecognizerContext and theUserDictionary objects here.
//...
WordList theUserWordList = new WordList();
foreach (string s in theUserDictionary)
{
theUserWordList.Add(s);
}
theRecognizerContext.WordList = theUserWordList;
//...
Note: The Strokes property of the RecognizerContext object must be empty before you set the WordList property. If the Strokes property is not empty, an exception is thrown. In addition, words should never be added to a word list after it has been assigned to a RecognizerContext object. Words that are added to the word list after it is assigned to the RecognizerContext object are not updated in the recognizer. To update the word list you must reassign the WordList object to the WordList property of the RecognizerContext object.
For maximum recognition accuracy, combine factoids with your application dictionary in an advantageous relationship. For more information about the relationship between factoids and application dictionaries, see Understanding WordLists, the RecognizerContext, and Factoids.
For an example of using application dictionaries with the InkEdit control, see Using an Application Dictionary with InkEdit.