Programming AI with Leaf/Adding to Leaf: the ALICE Chatbot
Introduction to the Leaf Chatbot for Windows 7
[edit | edit source]As is, Leaf can perform a number of actions when verbally requested. He also has a personality that changes with his experiences and time. Yet, conversationally he is quite limited and expanding the questions that he can answer requires a "Leafer" (A Leaf user) to add several lines of LISP code to the main code base. A simpler solution was required. The solution was formulated as three different chatbots. Two of these are limited to a short set of questions and answers that are stored in an external text file. The third chatbot, the one that will be discribed here, is a complete chatbot based on the ALICE chatbot created by Dr. Richard Walace. More properly "A.L.I.C.E." (Artificial Linguistic Internet Computer Entity), is a natural language processing chatterbot—a program that engages in a conversation with someone by applying heuristical pattern matching rules to the human's input. ALICE uses a form of XML called AIML. AIML is used to create your chatbot's personality and is easily configured and updated by editing the AIML text-based files.
The ALICE chatbot code itself is a set of java code based on ALICE which in turn is based on the original Eliza. There is a LOT that you can customize on it.
- USE AT YOUR OWN RISK! - USE AT YOUR OWN RISK! - USE AT YOUR OWN RISK! -
[edit | edit source]VERY IMPORTANT NOTE: The ALICE code was originally written for Windows XP. It writes and deletes file on your C:\\ drive. Windows 7 no longer allows users or software to write to the C:\\ drive and until I can re-compile the code to point elsewhere, to use this you will have to "unlock" your C:\\ "root" directory and turn off UAC. This WILL COMPROMISE the new Windows security and PUT THE USER'S PC AT RISK TO A HOST OF VIRUSES.
- USE AT YOUR OWN RISK! - USE AT YOUR OWN RISK! - USE AT YOUR OWN RISK! -
[edit | edit source]Files/Software Required:
- Leaf Software (fully installed and working)(Located in the Files section of the Yahoo Leaf group)
- The Java SDK
- The ALICE branch of Leaf (Leaf.lisp which is located in the Files section of the Yahoo Leaf group)
- The Leaf chatbot branch of ALICE "programD" (Located in the Files section of the Yahoo Leaf group)
Leaf Software
[edit | edit source]Leaf MUST be fully installed and working as per the instructions elsewhere in this book.
The Java SDK
[edit | edit source]Download and install the latest version of the Java SDK for Windows (version 7u4 at this writing.)
The ALICE branch of Leaf
[edit | edit source]The ALICE branch of Leaf modifies leaf.lisp to pass the phrases that he does not know to the chatbot software. The chatbot software then answers the phrases and passes them back to leaf to be read out loud. The main change is adding DICTATION MAX="INF" to the speech.xml file. This opens the recognition to any word. Without this statement in the speech.xml, Leaf would be limited to just the phrases that are listed there.
The Leaf <-> ALICE pipeline consists of two file "in.txt" and "out.txt" which are created and deleted in realtime in your c: drive.
Installing:
[edit | edit source]- Take your own speech.xml out of the Leaf directory and save it somewhere else.
- Drop the new speech.xml and the LeafChatbot.lisp files into your leaf directory.
- Unzip programD.zip
- Drop the entire programD folder into your c:\ directory
- Create a shortcut for \programD\bin\simple-console.bat on your desktop
Configuring:
[edit | edit source]You MUST create a new environment variable for ALICE ProgramD:
- Open up Windows 7 System Properties.
- Click the Environment Variables button.(Environment Varibles screen opens.)
- Click the New button. (New User Variable window opens.)
- Enter JAVA_HOME as the variable name.
- Enter C:\Program Files\Java\jdk1.7.0_04 (or your own path) as the variable value.
- CLick OK.(Closes the New User Variable window)
- Click OK. (closes the Environment Variables window.)
- Click OK. (Closes the System Properties window)
(You may need to reboot your PC.)
Running
[edit | edit source](Your speech recognition should have had at least two trainings for this to work.)
- Run the simple-console.bat AS ADMIN to start the bot. (Or launch it from a DOS cmd window.)
- Start Lispworks
- Compile and load Leaf Interfaces.lisp
- Compile and load LeafChatbot.lisp
- Open a listener and start (leaf)
You will need to speak VERY clearly since the entire vocabulary dictionary is being used.
First try saying something like "what time is it" Then try saying something like "what's up?" or "How are you?"
Customizing
[edit | edit source]To customize leaf's responses, you can edit many of the personality files inside of programD.
Moving the code to your own leaf.lisp (Always make a backup of the original code before editing!) You can look for the chatbot code inside of LeafChatbot.lisp and paste it CAREFULLY into the right places in your own leaf.lisp. It is in two places: 1. just after "name your bot" and just after all the phrases that lisp is to recognize. (search for 'chatbot'.) If you don't get it right, leaf will not work anymore.
--GOOD LUCK!!!
I'll answer any questions on the "Leaf AI Robot" online yahoo group.
--Thomas M