
CHAPTER 10
Recognition: Advanced Topics
10-32 Using Advanced Topics in Recognition
Note
Future versions of the system are not guaranteed to have the
autoAdd slot. You must verify that the returned value is non-nil
before using it.
◆
Adding Words to the User Dictionary 10
The following code fragment uses the AddWord method of the reviewDict
object to add words to the user dictionary. After adding one or more words, you
must call the
SaveUserDictionary function to make your changes to the user
dictionary’s system soup entry persistent.
local reviewDict := GetRoot().reviewDict;
if reviewDict then
begin
reviewDict:AddWord("myWord");
reviewDict:AddWord("myOtherWord");
SaveUserDictionary();
end;
The AddWord method returns true if the word was added successfully and
returns
nil if the word was not added; however, this function may also return nil
due to resource limitations.
It is possible to run out of system memory for dictionaries, with potentially serious
consequences. Do not rely on a specific number as the maximum amount of
dictionary entries that may be added safely.
If the Personal Word List slip is open when you add words to the user dictionary,
its display is updated automatically. An undo action is posted for this update.
IMPORTANT
Do not use the AddWordToDictionary global function to add
words to the review dictionary.
▲
Removing Words From the User Dictionary 10
The following code fragment uses the RemoveWord method of the reviewDict
object to remove a word from the user dictionary. After deleting the word, you
must call the
SaveUserDictionary function to write the changes to the user
dictionary’s system soup entry.
local reviewDict := GetRoot().ReviewDict;
if reviewDict then
begin
reviewDict:RemoveWord("myWord");
reviewDict:RemoveWord("myOtherWord");
SaveUserDictionary();
end;
Commentaires sur ces manuels