< Back

Chat Bot

The Loebner Prize Competition is held every year to evaluate artificial intelligence chat programs using the Turing Test. In 1950, Alan Turing proposed a test to measure the intelligence of computers. In the Turing, test a subject has a text chat with either a person in another room or with a computer (the subject does not know which). There are no limits to what the subject can chat about, but when done chatting the subject must choose whether they think they were talking to a real person or to a computer. The more frequently a the computer computer is labeled as human, the more intelligent the computer is, according to the test. (Whether the Turing test is actually a measure of intelligence is debatable, but one interesting thing to consider is, what if a computer was labeled as human more than an actual human?) One simple artificial intelligence chat algorithm is to just repeat what other people have said previously in the same context.


Setup

Create a directory called chatbot in your public_html directory.


Details

Write a simple artificial intelligence chat program. The program should use an associative array to associate phrases with responses. When a user submits a phrase to your PHP script, you should check if there is an entry for the phrase. If there is an entry it should display the response on the webpage. If there is not, then it should print a response for a random phrase in the array. Note, the array must be initialized with at least one phrase and response or else it will not be able to select a random phrase. After printing the response the submission form should be redisplayed, so the user can continue interacting.

The chat will be very boring unless the program’s response array is updated. The program should add the users input as a new response to the last phrase the program printed. That is, the program’s last output is the new key, and the user’s last input is the new value. The key should be converted to lowercase and stripped of all non-alphabetic characters to prevent capitalization and punctuation from affecting the look-up. If the key is already in the array, the value should be overwritten with the new response.

After every update, the your program should store the entirety of the programs associative array in a file. This way, your response array will grow after every use of the program.


Submission

You are required to submit a tar file of your chatbot directory. This submission is to be done via email, before Nov. 20th at 11:59 PM.