beautypg.com

Apple Newton Programmer’s Newton 2.0 (for Newton 2.0) User Manual

Page 410

background image

C H A P T E R 1 0

Recognition: Advanced Topics

10-34

Using Advanced Topics in Recognition

Removing Words From the Expand Dictionary

10

Normally, words are added to both the expand dictionary and the user dictionary
simultaneously. As a result, words removed from the expand dictionary generally
must also be removed from the user dictionary. The following code fragment uses
the

RemoveWord

method to remove a word from both the expand and the user

dictionaries. After deleting the word, you must call the

SaveUserDictionary

function to write the changes to the system soup.

local reviewDict := GetRoot().ReviewDict;

if reviewDict then

begin

// remove word & expansion from dictionaries

reviewDict:RemoveWord("BTW");

SaveUserDictionary();

end;

Retrieving Word Expansions

10

The following code fragment uses the

GetExpandedWord

method of the

reviewDict

object to retrieve the expansion associated with a specified word.

This method returns

nil

if the specified word is not found in the expand dictionary.

local reviewDict := GetRoot().ReviewDict;

if reviewDict then

local theExpansion := reviewDict:GetExpandedWord("BTW");

Retrieving the Auto-Add Dictionary

10

The auto-add dictionary (the list of new words to add to the user dictionary
automatically) resides in RAM and its size is limited to 100 words. The system
adds new words to this dictionary automatically when the cursive recognizer is
enabled and the Add New Words to Personal Word List checkbox in the Text
Editing Settings preferences slip is selected.

The Recently Added Words slip provides the NewtonScript interface to the
auto-add dictionary. You can use code similar to the following example to obtain a
reference to the RecentlyAdded Words slip.

local autoAddDict := GetRoot().AutoAdd;

Note

Future versions of the system are not guaranteed to have this
slot. You must verify that the returned value is non-

nil

before

using it.