File/graphnew.php

Description

GraphMaster

Contains the AIML matching functions for Program E

Functions
addtostar (line 501)

Deals with creating and adding to the star arrays

If a * or _ is part of the matched pattern, what is covered by that variable is then stored in the 'star arrays'. This function creates and adds words to that array or array element.

  • return: info is returned via call-by-reference variables.
  • usedby: graphwalker()
void addtostar (string $parton, string $word, array &$inputstarvals, array &$thatstarvals, array &$topicstarvals, integer $action)
  • string $parton: Can be input, that, topic.
  • string $word: The word that needs to be stored
  • array &$inputstarvals: contents of the *'s when they are part of the matching pattern input string
  • array &$thatstarvals: contents of the *'s when they are part of the matching pattern that string
  • array &$topicstarvals: contents of the *'s when they are part of the matching pattern topic string
  • integer $action: what action needs to be done, append to existing or create new.
arraytostring (line 673)

Turn an array into a string

take each element of the array and put all of them into one big string; one after the other.

  • return: the contents of the array into a string.
string arraytostring (mixed $myarray, array $myarray )
  • array $myarray
checkcache (line 607)

Check to see if exact input-that-topic exists in cache

GmCache is a log that contains all unique entries. If the exact same input-that-topic is requested that is found in GmCache, then it's template reference is used instead of traversing the binary AIML tree. Saving response time.

  • return: true/false Note, info is also transfere through the call-by-reference variables.
  • usedby: gettemplate()
boolean checkcache (string $combined, mixed &$template, array &$inputstarvals, array &$thatstarvals, array &$topicstarvals, array &$patternmatched, array &$inputmatched)
  • string $combined: the complete input in <input>word word<that>word word<topic>word word format.
  • array &$inputstarvals: contents of the *'s when they are part of the matching pattern input string
  • array &$thatstarvals: contents of the *'s when they are part of the matching pattern that string
  • array &$topicstarvals: contents of the *'s when they are part of the matching pattern topic string
  • array &$patternmatched: all the patterns that match input, i.e. multiple sentences are kept seperate.
  • array &$inputmatched: all the matched input.
debugger (line 52)

The debugger function

When uncommented, it will print the messages several functions will call.

  • return: Prints to HTML.
  • usedby: respond()
  • usedby: handlenode()
  • usedby: dographquery()
  • usedby: graphwalker()
  • usedby: gettemplate()
  • todo: the entire debug mechanism should be overhauled, this simple one line function doesn't cut it. Perhaps make use of several levels, function names and or timing to spefiy which part to debug.
void debugger (string $msg, integer $val)
  • string $msg: The message to be printed in debugger mode
  • integer $val: no idea what this does, it's used in every function call but not in the function itself
dographquery (line 392)

Does a database query for graphwalker()

Retrieves the ID, ordera, isend of the word to be searched $query="select id,ordera,isend from patterns where word='" . addslashes($word) . "' or word is null and parent=$parent";

  • return: contains ID, ordera and isend from the query. note: call-by-reference array exists too.
  • global: integer $numselects: The number of queries that have been executed
  • usedby: graphwalker()
  • uses: debugger()
  • todo: The array returned is also returned via call-by-reference. Investigate which should be chosen.
array dographquery (array &$whichresult, mixed $word, mixed $parent, string $query)
  • string $query: The SQL code to be executed
  • array &$whichresult: contains ID, ordera and isend from the query. note: call-by-reference
fastforward (line 556)

Fast forward to the processing of the next context

Remainder of the user's input covered by a *. So so add everything up to the next context (<that> & <topic>) to the star.

  • return: words to be saved by addtostar()
  • usedby: graphwalker()
  • todo: $newremains is a variable that is created, and filled but not returned. It is perhaps old code that pre dates addtostar() that saves the returned value in graphmaster().
string fastforward (string $word, string $ffremains)
  • string $word: Current processed word
  • string $ffremains: Words that remain to be processed.
fillcache (line 651)

Add an entry in the GMcache table

  • global: integer $selectbot: The selected bot.
  • usedby: gettemplate()
void fillcache (string $combined, string $mytemplate, string $inputstarvals, string $thatstarvals, string $topicstarvals, string $patternmatched, string $inputmatched)
  • string $combined: the complete input in <input>word word<that>word word<topic>word word format.
  • string $mytemplate: the reply to the input
  • string $inputstarvals: contents of the input star
  • string $thatstarvals: contents of the that star
  • string $topicstarvals: contents of the topic star
  • string $patternmatched: the AIML category pattern that matches the input
  • string $inputmatched: the input that matched the category.
findtemplate (line 467)

Retrieve the template from the templates table

Get the template from the templates table. and return it.

  • return: The contents of <template/> for this category.
  • usedby: gettemplate()
  • todo: The name gettemplate() and findtemplate() are too similar.
string findtemplate (integer $id)
  • integer $id: The ID of the template to be returned
gettemplate (line 83)

Get the template for the input, that, and topic

Get the template for a paticular pattern and dialogue situation. If the pattern, including topic and that, was found in the cache, the mathcing routine is circumvented and that template used. This saves time.

string gettemplate (string $input, string $that, string $topic, array &$inputstarvals, array &$thatstarvals, array &$topicstarvals, array &$patternmatched, array &$inputmatched)
  • string $input: The user's input
  • string $that: The bot's previous output
  • string $topic: The contents of the AIML tag <topic>
  • array &$inputstarvals: contains the contents of the *'s when they are part of the matching pattern input string
  • array &$thatstarvals: contains the contents of the *'s when they are part of the matching pattern that string
  • array &$topicstarvals: contains the contents of the *'s when they are part of the matching pattern topic string
  • array &$patternmatched: contains all patterns that were found. An input can have more than one sentence which are processed seperately.
  • array &$inputmatched: contains all the individual sentences of a user's input.
graphwalker (line 152)

The graphwalker function finds the pattern that matches the combined input of input, that, and topic.

Then it returns the template that matches. It is recursive.

integer graphwalker (string $input, string $parent, string $timesthrough, boolean $onwild, string $parton, array &$inputstarvals, array &$thatstarvals, array &$topicstarvals, array &$patternmatched)
  • string $input: The user's input
  • string $parent: The word's parent ID
  • string $timesthrough: Number of recursions????
  • boolean $onwild: whether or not a wildcard is processed (Anne: I think)
  • string $parton: Can be input, that, topic.
  • array &$inputstarvals: contents of the *'s when they are part of the matching pattern input string
  • array &$thatstarvals: contents of the *'s when they are part of the matching pattern that string
  • array &$topicstarvals: contents of the *'s when they are part of the matching pattern topic string
  • array &$patternmatched: contains all patterns that were found. A user's input can have more than one sentence.

Documentation generated on Wed, 12 Jan 2005 12:24:46 +0100 by phpDocumentor 1.3.0RC3