![]() |
License / Documentation home / Help and feedback | ![]() |
MIT provides a way of controlling servers using Turn Management, a set of resources which was one of the initial inspirations for the Hub program files. The Galaxy library provides a dispatch function named turn_management which implements this toplevel control. We describe it briefly here. At least part of this documentation will take the form of server documentation, since this is a good deal of the behavior from the programmer's point of view.
As an illustration
of how to use Turn Management for dialogue control, we will use the pegasus
server, a flight reservations server.
int function_name (GAL_DOMAIN_SVR *dc);Valid return values are:
The file containing the functions should be kept in the server directory. A header file, containing dialogue control function prototypes, will be automatically generated at compile time. (See below.)
As an example, pegasus has a function called default_action which handles the undefined case by replying with a "cant_handle" clause.
int default_action(GAL_DOMAIN_SVR *dc)See below for an example rule which states the required conditions in order for default_action to be executed.
{
if (!dc->reply_frame)
dc->reply_frame = Gal_MakeFrame("cant_handle", GAL_CLAUSE);return(DIALOGUE_STOP);
}
Another example is the need_destination function. A "need_destination" clause is created for the given topic and then added to the system initiative.
int need_destination(GAL_DOMAIN_SVR *dc)See below for an example rule which states the required conditions in order for need_destination to be executed.
{ Nframe topic;
topic = Gal_GetFrame(dc->request_frame, ":topic");
dc->reply_frame = Gal_MakeFrame("need_destination", GAL_CLAUSE);
fr_setsprop(dc->reply_frame, ":topic", make_tframe(copy_nframe(topic)));
Gal_AddSystemInitiative(dc, "destination", NULL);
return(DIALOGUE_STOP);
}
The default dialogue control file is assumed to be ../System/<server_name>.dctl. The dialogue control file can also be specified as a command line argument. If no file is specified and the default file does not exist, execution is aborted.
A header file, based on the dialogue control
file, is automatically generated at compile time. This header file
contains the function prototypes for each operation listed in the dialogue
control file. See below
for more details.
static char *oas[] = {This server also accepts the standard server arguments. See the oa library for details.
"-dialogue_script name", "script for dialogue control in domain server", NULL, NULL
};
Each operation returns a value which has
implications for the flow of control through the script.
Valid
return values are:
A rule in a dialogue control script
is similar to a rule in a
Hub program except that the RULE:
identifier is not used. Otherwise, the syntax is identical:
<alphanumeric expression> --> <operation>See the table of Valid Operators for Constructing Rules.where the alphanumeric expression is ( [!] [X %] <key> [comparison] [<value>] [&] [|])
A dialogue control script can also contain
comments. Any line beginning with a semicolon is interpreted as a
comment.
on_time which | departure_time %which | arrival_time %which -->
mark_status
; on_time must be equal to which,
or departure_time must contain
which,
or arrival_time must contain
which in order for the mark_status
operation to be called.
destination & filtered !% to --> filter_to_airport
; If destination
exists and filtered does not
contain to, then call execute
filter_to_airport.
num_found >1 --> speak_multiple
; If num_found
is greater than 1, execute speak_multiple.
!sql_query & !destination & !flight_number -->
need_destination
; If there is no sql_query
and no destination and no
flight_number,
execute need_destination.
--> default_action
; If no other rule's conditions have been
satisfied, execute default_action.
In order for this to work as the default, the rule has to be the last rule
in the set.
GAL_DIALOGUE_FUNCTION(<op_name>)with a GAL_DIALOGUE_FUNCTION declaration for each server dialogue control function. Then the user adds the following header information to exactly one of the server source files:
GAL_DIALOGUE_FUNCTION(<op_name>)
...
#define SERVER_FUNCTIONS_INCLUDE "<server_declaration_file_name>"where <server_declaration_file_name> and <dctl_declaration_file_name> are replaced with the appropriate names of the server declarations file and the file created here, respectively., As with the old style of server header generation, the server header file includes the appropriate behavior for the dialogue header file. Note that this new style works in conjunction with the new style of declaring server information; in particular, the GAL_SERVER_SW_PACKAGE() macro is used to incorporate the dialogue control module.
#include <galaxy/server_functions.h>#include <domain_svr/domain_svr.h>
#define DIALOGUE_FUNCTIONS_INCLUDE "<dctl_declarations_file_name>"
#include <domain_svr/dialogue_functions.h>
Here is an example of what the MIT pegasus server would look like if it used the new style of headers:
------ pegasus-dialogue.hGAL_DIALOGUE_FUNCTION(give_help)
GAL_DIALOGUE_FUNCTION(repeat_response)
...------ pegasus-server.h
GAL_SERVER_NAME(pegasus)
GAL_SERVER_PORT(11100)
GAL_SERVER_OP(turn_management)
GAL_SERVER_SW_PACKAGE(MITDialogue)------ functions.c
...
#define SERVER_FUNCTIONS_INCLUDE "pegasus-server.h"
#include <galaxy/server_functions.h>
#include <domain_svr/domain_svr.h>
#define DIALOGUE_FUNCTIONS_INCLUDE "pegasus-dialogue.h"
#include <domain_svr/dialogue_functions.h>
...
GAL_DOMAIN_SVR *Gal_InitTM(int
argc,
char **argv)
Initializes the domain server. The
dialogue script may be specified by the -dialogue_script
argument shown above; otherwise,
the dialogue file defaults to "../System/<server_name>.dctl".
If no dialogue script is provided and the default file is not found, the
function returns a fatal error. This function is called by Gal_DialogueInitServer.
You can also add support for printing out usage information as follows:
void _GalSS_print_usage(int argc, char **argv)void Gal_DialoguePrintUsage(int argc, char **argv)
{
Gal_DialoguePrintUsage(argc, argv);
}
turn_management
runs
the dialogue control tools (via the dialogue
control file) and generates a domain-specific response.
parameter | type | optional | depends on | description/constraints | |
IN: | :key_value | string | yes | key/value paraphrase of input | |
:kv_lang | string | yes | key/value paraphrase language; if not present in input, will be set from system's default key-value language, which is "dialogue" | ||
:parse_frame | frame | parsed input string | |||
:request_frame | frame | input plus context | |||
:tm_state | frame | yes | previous state of turn manager | ||
OUT: | :reply_frame | frame | will have the form {... :domain <string> :comment_tlist <list> :continuant <frame> :db_tlist <list> ...} | ||
:list | yes | (no examples) | |||
:map | yes | (no examples) | |||
:image | yes | (no examples) | |||
:tm_state | frame | yes | previous dialogue state | ||
:filter_list | frame | value is {... :Flist <list of strings> :Ftype <string> :Fcategory <string> :Fkey <string> ....}. Describes words which ought to be present in the :parse_frame. Used by a number of servers to provide preferences for choosing among frames. | |||
:discourse_update | frame | yes | frame for context tracking out to add to the discourse history | ||
:system_initiative | frame | yes | query to present to the user |
Because many servers utilitize the Turn Management dialogue control capabilities, it is recommended that the dot notation be used for specific servers when the turn_management operation is included in a Hub program rule:
RULE: :request_frame & :key_value & :domain Pegasus --> pegasus.turn_management
RULE: :request_frame & :key_value & :domain Jupiter --> jupiter.turn_management
![]() |
License / Documentation home / Help and feedback | ![]() |