Thanks for a great project, I have 2 questions
1- Is it possible for AIMLbot to persist a state, i.e save a user profile, load it upon request.
2- Can it learn things, i.e I say "my dad 's name is albert", then if asked "what's my dad's name ?" it would answer "Albert"
Thanks for the positive comments...
To answer your questions:
1. Yes, but you'll have to write it. The reason I didn't include this feature in the core library is that how one might persist a user's state will depend on the sort of project you're writing. However, I tried to give a helping hand by storing all the predicates for a user (i.e. their settings) in the public Predicates object that is of type AIMLbot.Utils.SettingsDictionary. The SettingsDictionary class defines an attribute called DictionaryAsXML that returns the dictionary of settings as an XmlDocument that can be then written to a file system, database or wherever you so desire. In addition it defines a method called loadSettings that is overloaded to take either the path to an XML file containing the dictionary settings or an XmlDocument object containing the settings. With these two features you can persist the user's predicates in whatever way is best for your application.
2. Yes, you'd do it using the following two AIML categories like this:
<pattern>MY DAD S NAME IS *</pattern>
OK, <star/> is your dad's name.
<pattern>WHAT IS MY DAD S NAME</pattern>
Your dad's name is <get name="dadname"/>.
The first category is using the "set" tag to put whatever was matched by the * in the input "pattern" (referenced by the "star" tag). It is enclosed in the "think" tag so it doesn't appear to the user. What has really happened is that a new predicate (called "dadname") has been added to the Predicate object in the User object with the value of whatever your dad's name is.
The second category uses the "get" tag to grab the setting from the predicate list I mention above.
1. Is it also possible to create a new AIML category automatically? Let's say to create AIML categories on the fly, while 'talking' to the bot?
2. I can tell him my Name, but it is not persistent when I restart it. How can I save such settings?
Thanks for your great work!
Thanks for the interesting questions. The short answers are:
The longer answers are:
1. Use the loadAIMLFromXML method found in the Bot class. This method needs to be passed two arguments:
XmlDocument newAIML - An XmlDocument that contains the new category wrapped in aiml tags (eg: <aiml><category><pattern>HELLO THERE</pattern><template>How do you do?</template></category></aiml>)
string filename - Normally the name of the file that contained the source aiml being processed. In this case I'd just pass something like "autogenerated". In version three this argument is (will be) renamed to "URI" as the source of any aiml might be on the filesystem or on a network or even embedded in a web-page.
So you end up with code looking like this:
XmlDocument myDoc = new XmlDocument();
myDoc.LoadXml("<aiml><category><pattern>HELLO THERE</pattern><template>How do you do?</template></category></aiml>");
string filename = "autogen";
You might be interested to know that I'm currently planning version three - this will still be compatible with the basic AIML standard but will also include some extensions of my own design to make the bot capable of much more dynamic conversation. This will include a means of specifying new categories on-the-fly. I'm writing up a roadmap at the moment and will post it on my blog (and announce it in the news section) with a view to getting comments and suggestions. Watch this space...
2. Put simply, you need to save the Predicates object associated with your user. To do this call the Predicates.DictionaryAsXML attribute to get the object as an XmlDocument. Save your XML in the usual .NET way. To load the predicates use the Predicates.loadSettings method (pass it either the path to the XML file or an XmlDocument version of it).
You might be interested to know that the next release will include a modified version of the AIMLGUI windows client that will include example code demonstrating how to user predicate information AND all the user's conversation history. I'm working on it as we speak!
Hope this helps.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.