Working with a Dictionary
One of the responsibilities of the checking subsystem is to check the user dictionary for acceptable words during recognition, provided a user dictionary has been set. To use a user dictionary during recognition, one must be created or opened using the SetUserDictionary method before calling the Recognize method. The DictionaryDefaultSection property contains the name of the user dictionary and the default section of the user dictionary.
Creating a New User Dictionary
To create a new user dictionary, set the call the SetUserDictionary method with the bCreateUD parameter set to TRUE. This will create the dictionary in memory. Add items to the dictionary using the AddItemToUserDictionary method. Once all the desired changes/additions have been made to the new dictionary, do the following:
set the DictionaryFileName property to the proper name
set the DictionaryDefaultSection property to the desired default section
set the DictionaryItemAttribute property to indicate how to add the items to the dictionary
call the SetUserDictionary with the bCreateUD parameter to FALSE to save the dictionary to the file.
Loading an Existing User Dictionary
To load an existing user dictionary that has been saved to a file, set the DictionaryFileName property to that name of the file containing the user dictionary and call the SetUserDictionary method with the bCreateUD parameter set to FALSE.
While the user dictionary is being used, it may have material added or removed. Items may be added using the AddItemToUserDictionary method or removed using the RemoveItemFromUserDictionary method. The DictionaryState indicates whether the user dictionary has been changed while it has been open.
Getting Information from the User Dictionary
A user dictionary consists of one or more sections (folders or categories) and each section can have one or more items (folder contents). When the user dictionary is opened or created, the user dictionary is opened to a specific default section. The default section for a user dictionary is set in the DictionaryDefaultSection property. If the user dictionary is saved to a file, the default section set in the DictionaryDefaultSection property is stored with the dictionary so that if that file is later opened, the dictionary will be opened to that section. When an existing user dictionary is opened, the DictionaryDefaultSection property is updated with the name of the default section. The default section is automatically the first section in the dictionary. To get the name of a section in a dictionary, use the GetUserDictionarySection method. This method returns either the first section of a dictionary, or the next section in the dictionary, depending on the bFirst parameter. Items of each section can be obtained by calling the GetUserDictionarySectionItem method. This method returns either the first item of a section, or the next item in a section, depending on the bFirst parameter.