Util.php, Utility functions
Contains reusable functions for Program E
Class | Description |
---|---|
![]() |
Class to hold the reponse |
subs.inc has all of the substitution values and sentence splitter values
Store the clients inputs into the database.
This is an array because it separates on .'s and other sentence splitters. Stores these in the dstore table of the database.
Store the bots responses into the database
This is an array because it separates on .'s and other sentence splitters. Stores these in the thatindex table of the database.
Get a value for some variable set by the user in AIML.
In the template (<template> ... </template>) variables can be set and used during matching. after matching these variables are stored in the table dstore. This function retrieves the value of a stored variable. This type of variable is also called a 'predicate'.
Get information about the bot that was entered in the startup.xml
In startup.xml there are a number of bot-varables called in AIML as <bot name="foo"/> These are stored in the table 'bot' and this function retrieves (ex.) the value of bot-variable "foo".
Set the value for an AIML variable
Function to store the variable name and it's contents into the dstore table. It doens't update the table, just the first insert.
This function will clean up old data in the database that is not needed according to user defined settings.
Deletes entries in the database tables dstore, thatstack, thatstackindex and if set also conversationlog.
Do a first to second person replacement
Replaces, for example, "with you" to "with me". he gender related words and phrases that are used can be found in subs.inc and originally in the startup.xml
Do a first to third person replacement
Replaces, for example, "I was" to "he or she was". he gender related words and phrases that are used can be found in subs.inc and originally in the startup.xml
Reverse the gender of a phrase
Replaces, for example, 'he' in the string to 'she'. The gender related words and phrases that are used can be found in subs.inc and originally in the startup.xml
Get the child nodes of the XML tree
Retrieve the child nodes of the XML tree. This is a recursive function.
get the current date formatted.
Should look like: Wed Nov 14 18:09:55 CST 2002
Get the previous thing the client said
Retrieve the entire previous input of the user from the dstore table.
Gets the numer of AIML categories stored in the database
The size of the AIML knowledgebase is counted in categories. This function will count the number of categories based upon the number of records in the templates table.
Get the previous thing the bot said
Retrieve from the thatindex table the previous output, per sentence, of what the bot said from the thatindex en thatstack table.
Get an XML tree
Create an XML tree in array form from a large string.
Insert gossip into the database
Gossip is an AIML tag where the user can store bits of information from one user and then reuse is in the conversation of another user. It is the only tag that behaves this way. Stores value into the gossip table of the database.
Check to see if a tag is a custom tag.
Program E supports additional, non AIML 1.0x specified, custom tags. This function checks to see if the encountered XML tag is indeed a custom AIML tag. If it is a custom tag, it will then the appropriate function to use in &$functicall.
Check if a tag is an old style AIML tag.
If it is then return its new name and the fact that it is deprecated. This information is not send back through the return value, but by using call-by-reference variable &$ttag.
Load all custom tags
Create a global accessible array with all custom tags, based upon the custom tag functions (ct_FunctionName()).
Logs the whole input and response
Saves the input and response into the conversationlog table of the database.
Look up the bot's ID number
From the bot's name, retrieve it's bot ID number from the bots table in the database. This funtion requires that each bot has a uniqe name to function.
Substitution routine
Is used in combination with for example firstthird() gender(). The myfunc() is called from these functions from the arrays generated in subs.inc by makesrphp().
When doing substitution myfunc replaces the words to be substituted with ~~x~~ where x is an incremented integer instead of what should eventually be substituted. Then when all substitution is done another function will go through and replace the ~~x~~ with the real value.
Take the user input and do all substitutions and split it into sentences
The matching process searches a match for every sentence and in the end combines all those individual matches into one reply. This funtion splits the sentences of the user's input, replaces the words that need to be subtituted (found in startup.xml).
Retrieve timer data
Get the running time the timed script
Start a timer
Save the start time of the to be timed script
Stop a timer
Save the stop time of the to be timed script
Change the case of the keys of an array to all uppercase
Array keys can be number or strings. If strings then it's a good habit to use only uppercase. This is sadly not always the case. This function makes sure that they are.
Which bot is selected
Returns the bit of SQL query that limits the results to the selected bot.
Documentation generated on Wed, 12 Jan 2005 12:24:49 +0100 by phpDocumentor 1.3.0RC3