background image
C H A P T E R 1 8
Intelligent Assistant
18-18
Using the Assistant
Sample PostParse Method
18
The following code fragment is an example of a
PostParse
method that tests for
the existence of the
value
slot and accesses its content:
PostParse: func()
begin
local thePhraseText;
// self is the task frame
if hasSlot(self, 'value) then
thePhraseText := self.value;
else
// handle missing input
end;
// display phrase text in task slip
end;
end;
Defining the Task Template
18
Your task template defines a primary action and its supporting data structures.
Take the following steps to define a task template:
1. Define a frame containing the
value
,
isa
,
primary_act
,
PostParse
,
signature
,
preConditions
, and
score
slots. Subsequent bullet items in
this section describe the contents of these slots.
2. Assign the frame to a slot, variable, or constant that is the name of the task
template.
3. Place a string in the
value
slot that identifies the task that this template defines.
4. Place the
'task_template
symbol in the
isa
slot.
5. Place the name of the slot or variable defining your primary action in the
primary_act
slot.
6. Place the name of the slot, variable or constant defining your
PostParse
method in the
PostParse
slot.
7. Place in the
signature
slot an array of the names of all action and target
templates required to complete this task.
8. Place an array of symbols in the
preConditions
slot that specifies the names
of slots the Assistant must create to hold frames built from the templates
specified in the
signature
array. The
preConditions
and
signature
arrays must have the same number of elements. Furthermore, the symbols in the
preConditions
array must appear in the same ordinal position as their
counterparts in the
signature
array; that is, the first element of the
© 2007-2017, o7 studio » при воспроизведении материала сайта ссылка обязательна