background image
C H A P T E R 1 0
Recognition: Advanced Topics
Using Advanced Topics in Recognition
10-33
The
RemoveWord
method returns
true
if the word was removed successfully and
returns
nil
if the word was not removed. This method returns
nil
and does not
remove the specified word if there are differences in case between the word in the
dictionary and the word passed as the argument to the
RemoveWord
method. This
method also returns
nil
when the word to be removed is not present in the
review dictionary.
IMPORTANT
Do not use the
RemoveWordFromDictionary
global function
to make changes to the review dictionary; instead, use the
appropriate review dictionary methods.
Adding Words to the Expand Dictionary
10
The expand dictionary (the dictionary that defines word expansions) is kept in RAM,
and its size is limited to 256 words. To manipulate the expand dictionary, you send
messages to the
reviewDict
object residing in the root view. The system provides
methods for adding words and their associated expansions to this dictionary;
retrieving the expansions associated with words; removing words and expansions
from this dictionary; and saving expansion dictionary changes to the system soup.
To add a word and its expansion to the expand dictionary, you must send the
AddExpandWord
message to the
reviewDict
object. Words added to the
expand dictionary must first be recognized and present in the user dictionary. If
necessary, you can use the
AddWord
method of the
reviewDict
object to add
the word to the user dictionary before adding it to the expand dictionary. After
adding one or more words to the expand dictionary, you must call the
SaveExpandDictionary
function to write your changes to the system soup, as
the following code fragment illustrates.
local reviewDict := GetRoot().ReviewDict;
// word must be present in user dict before adding to expand dict
if reviewDict then
begin
if not LookupWordInDictionary(reviewDict, "BTW") then
begin
reviewDict:AddWord("BTW");
SaveUserDictionary();
end;
reviewDict:AddExpandWord("BTW", "by the way");
// write changes to system soup
SaveExpandDictionary();
end;
© 2007-2017, o7 studio » при воспроизведении материала сайта ссылка обязательна