background image
C H A P T E R 1 8
Intelligent Assistant
18-8
About the Assistant
You define the
PostParse
method in your task template. Your
PostParse
method must perform any actions required to complete the primary task. The
PostParse
method usually acts as a dispatching method that executes the
subtasks comprising the primary action. In doing so, the
PostParse
method may
validate data and retrieve information that the Assistant was unable to find on its own.
IMPORTANT
Once your
PostParse
method is invoked, it is in complete
control of the error-handling and user interface on the Newton.
Your
PostParse
method must include any code necessary to
complete the primary action, such as code required to display a
task slip, validate input, and handle errors.
Matching Words With Templates
18
This section discusses the process of extracting words or phrases from user input
and matching them to templates registered with the Assistant. In particular, this
section provides more detail regarding unmatched words, partially matched
phrases, and words that match multiple templates.
When the user taps the Assist button, the system passes the current input string to
the
ParseUtter
function, which matches words in the input string with elements
in the lexicons of templates currently registered with the Assistant. Normally, you
do not need to call the
ParseUtter
function yourself; however, you can
experiment with the Assistant by passing strings to this function in the NTK
Inspector window.
When parsing the input string, the
ParseUtter
function matches entire words only.
For example if the word
"telephone"
appears in a template's
lexicon
slot,
that template is not matched when the word
"phone"
appears in the input string.
The Assistant's matching process is case insensitive; thus, if the word
"phone"
appears in a registered template's
lexicon
slot, that template is matched when
"Phone"
or
"phone"
appears in the input string.
If absolutely nothing in the input string is matched, the return result of the
ParseUtter
function is unspecified. However, if any word in the input string is
matched, the
ParseUtter
function returns a frame containing frames created
from the appropriate templates and additional information about the matched
words. For more information about the result frame returned by the
ParseUtter
function, see the description of this function in Newton Programmer's Reference.
When none of the words in the input string matches an action template, the
Assistant may use the information it did match to try to determine a likely action.
For example, when the user enters the phrase
"buzz 555-1234"
, the Assistant
does not match the word
"buzz"
to an action template but it can identify
© 2007-2024, o7 studio » при воспроизведении материала сайта ссылка обязательна