background image
C H A P T E R 1 0
Recognition: Advanced Topics
Using Advanced Topics in Recognition
10-27
This approach works well for small dictionaries; for most large dictionaries,
however, it is far more efficient to populate the dictionary from saved soup data.
You should store custom dictionary data in a soup so that it is safely stored and
persistent across soft resets.
IMPORTANT
Do not use the
AddWordToDictionary
global function to add
words to the review dictionary; instead, use the appropriate review
dictionary methods.
Removing Words From RAM-Based Dictionaries
10
You can use the
DeleteWordFromDictionary
function to remove a specified
word from a specified RAM-based dictionary. Note that this function does not
make permanent changes to soups. After calling this function you must write your
changes to the appropriate soup.
IMPORTANT
Do not use the
DeleteWordFromDictionary
function to
remove words from the review dictionary; instead, use the
appropriate review dictionary methods.
Saving Dictionary Data to a Soup
10
Once you have added all of your dictionary entries, your RAM-based custom
dictionary is ready for use. However, it would be inefficient to build it from scratch
each time you need it, especially if it is large. Instead, you can store a binary
representation of the dictionary data in a soup and use this soup data to restore the
custom dictionary.
The
NewDictionary
function returns an identifier used to reference the
dictionary; in the previous example, this identifier was stored in the
mySpecialDictionary
slot defined in the base view of the application. You can
pass this identifier as the
GetDictionaryData
function's argument. This
function returns a binary representation of the dictionary data (the words or items).
You can then place this binary object in a slot in a frame and add the frame to a
soup. The following code fragment assumes that the soup
kSoupName
is a valid
soup created according to the Newton DTS soup-creation guidelines.
// get a soup in which to save the data
mySoup := GetUnionSoupAlways (kSoupName);
// create binary representation of dictionary data
local dict := GetRoot().
appSym
.mySpecialDictionary;
local theObj:= GetDictionaryData(dict);
© 2007-2017, o7 studio » при воспроизведении материала сайта ссылка обязательна