Overview of
the templ_database () Function
The function takes as its arguments the sentence and an
integer value representing the identity of the question.
The first part of the function is to translate the integer
values associated with the question�s identity, into words.
The question�s identities used by the template can then be
matched to these. This means that a response generated for a
�what� question can be matched to a template from the
�what � responses in the template. This is achieved by
systematically working through the template, taking each line
into a buffer and comparing the contents to the identity of the
sentence. Once a match is found, an appropriate template is
randomly selected. The templates contain a �[� symbol.
This denotes the point of insertion for the response. The
insertion is executed by using temp_man(templates[rand() %
no_r],sentence)
Overview of
the temp_man () Function
The temp_man(templates[rand()% no_r],sentence) takes as its
arguments, the randomly selected template and the sentence (the
response). The function creates three arrays, splits the template
at the �[� symbol and places the first half in an array
called part 1. The second half is placed in an array called part
2. The array output then has part one placed in it. Next a space
is placed in the array. The response is then placed into output
and another space added. Finally, part 2 is added to output with
a null character appended to it. The output is then passed to
display.
Overview of
the display ()function
The display () function takes as its arguments the output and
sends the format of the web page as HTML code the output is sent
within this code. The first line that is passed to the web
browser is the CGI directive. In our case, the content of the web
page is HTML page, i.e. "Content-Type: text/HTML".
|