beautypg.com

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

Page 658

background image

C H A P T E R 1 8

Intelligent Assistant

18-12

About the Assistant

value

"Bob Anderson"

, that element of the

phrases

array stores the entire

string

"Bob Anderson"

, as the following code fragment shows:

// input string is "call bob anderson"

{…

phrases: ["bob anderson", "call"],

…}

Note that strings may appear in the

phrases

array in a different order than they

did in the original input to the Assistant.

The OrigPhrase Slot

18

The original input phrase is returned as a single string that resides in the task
frame’s

origPhrase

slot. You can examine this slot to determine the number and

ordering of words in the original input string.

The Value Slot

18

Some values can be parsed correctly only by using a lexical dictionary that
describes their format. These values include formatted numbers such as phone
numbers, currency values, dates, and times.

When the Assistant uses a lexical dictionary to parse an object, it returns the parsed
phrase as a single string in the

value

slot. For example, if the user had entered the

phrase

"Call 555-1212"

the Assistant would store the phone number in the

value

slot, as shown in the following example:

{...

input: [{isa: {value: "action"},

Lexicon: [["call", "phone", "ring", "dial"]],

value: "call"},

{isa: {isa: {isa: {#4B9F1D},

value: NIL,

Lexicon: [#4B9FA1]}},

value: "555-1212"}],

...}

Note that the

value

slot is created only when the Assistant uses a lexical

dictionary to parse a formatted string such as a time, date, phone number, or
monetary value.