Dear Sirs & Madams:
In brief
a) general advice for implementing an automated email response system that keeps track of conversation to date
b) If this is correct for AIML 1.0.1
<aiml version="1.0.1" xmlns="http://alicebot.org/2001/AIML-1.0.1"\
xmlns:html="http://www.w3.org/1999/xhtml"\
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\
xsi:schemaLocation="http://alicebot.org/2001/AIML-1.0.1 http://aitools.org/aiml/schema/AIML.xsd">
what is correct for AIML 1.0?
Thank you
Misha
---
I am trying to bootstrap a simple automated email response system based on an existing chatbot agent/implementation (ideally open source).
I have had some success with Program D:
http://aitools.org/Program_Dand the AAA AIML set:
http://www.alicebot.org/aiml/aaa/I have also tried the Chomsky AIML set:
http://alicebot.wikidot.com/forum/t-80187/chomsky-aiml-setI have even tried the updated one:
http://www.aimlpad.com/chomskyaiml.zipNo luck. I am using this script to convert:
rm chomskyAIML/*
cd chomskyAIML.input
for NAME in `ls *.aiml`; do
echo $NAME
sed 's@<aiml>@<aiml version="1.0.1" xmlns="http://alicebot.org/2001/AIML-1.0.1"\
xmlns:html="http://www.w3.org/1999/xhtml"\
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\
xsi:schemaLocation="http://alicebot.org/2001/AIML-1.0.1 http://aitools.org/aiml/schema/AIML.xsd">\
@g' $NAME | sed 's@<aiml version="1.0">@<aiml version="1.0.1" xmlns="http://alicebot.org/2001/AIML-1.0.1"\
xmlns:html="http://www.w3.org/1999/xhtml"\
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\
xsi:schemaLocation="http://alicebot.org/2001/AIML-1.0.1 http://aitools.org/aiml/schema/AIML.xsd">\
@g' | sed 's@<br />@<html:br/>@g' | sed 's@<br/>@<html:br/>@g' | sed 's@<meta@<html:meta@g' | sed 's@<p />@<html:p/>@g' | sed 's@<a @<html:a @g' | sed 's@</a>@<html:/a>@g' > ../chomskyAIML/$NAME
done
and getting errors like:
[2010-02-09 16:59:19,542] INFO: Loading file:/home/misha/personal/ProgramD/aiml/chomskyAIML/chomsky079.aiml....
[2010-02-09 16:59:19,543] WARN: Error parsing "file:/home/misha/personal/ProgramD/aiml/chomskyAIML/chomsky079.aiml": Element or attribute do not match QName production: QName::=(NCName':')?NCName.
Element or attribute do not match QName production: QName::=(NCName':')?NCName.
[2010-02-09 16:59:19,547] INFO: Loading file:/home/misha/personal/ProgramD/aiml/chomskyAIML/update040.aiml....
[2010-02-09 16:59:19,553] WARN: Error parsing "file:/home/misha/personal/ProgramD/aiml/chomskyAIML/update040.aiml": Element or attribute do not match QName production: QName::=(NCName':')?NCName.
Element or attribute do not match QName production: QName::=(NCName':')?NCName.
[2010-02-09 16:59:19,554] INFO: Loading file:/home/misha/personal/ProgramD/aiml/chomskyAIML/chomsky093.aiml....
[2010-02-09 16:59:19,561] INFO: Loading file:/home/misha/personal/ProgramD/aiml/chomskyAIML/update019.aiml....
[2010-02-09 16:59:19,586] WARN: Error parsing "file:/home/misha/personal/ProgramD/aiml/chomskyAIML/update019.aiml": Invalid byte 2 of 3-byte UTF-8 sequence.
Invalid byte 2 of 3-byte UTF-8 sequence.
[2010-02-09 16:59:19,588] INFO: Loading file:/home/misha/personal/ProgramD/aiml/chomskyAIML/chomsky082.aiml....
[2010-02-09 16:59:19,590] WARN: Error parsing "file:/home/misha/personal/ProgramD/aiml/chomskyAIML/chomsky082.aiml": Element or attribute do not match QName production: QName::=(NCName':')?NCName.
Element or attribute do not match QName production: QName::=(NCName':')?NCName.
[2010-02-09 16:59:19,591] INFO: Loading file:/home/misha/personal/ProgramD/aiml/chomskyAIML/chomsky051.aiml....
[2010-02-09 16:59:19,595] INFO: Loading file:/home/misha/personal/ProgramD/aiml/chomskyAIML/chomsky108.aiml....
[2010-02-09 16:59:19,652] INFO: Loading file:/home/misha/personal/ProgramD/aiml/chomskyAIML/chomsky010.aiml....
[2010-02-09 16:59:19,709] WARN: Error parsing "file:/home/misha/personal/ProgramD/aiml/chomskyAIML/chomsky010.aiml": cvc-complex-type.4: Attribute 'name' must appear on element 'bot'.
cvc-complex-type.4: Attribute 'name' must appear on element 'bot'.
[2010-02-09 16:59:19,710] INFO: Loading file:/home/misha/personal/ProgramD/aiml/chomskyAIML/chomsky037.aiml....
[2010-02-09 16:59:19,713] WARN: Error parsing "file:/home/misha/personal/ProgramD/aiml/chomskyAIML/chomsky037.aiml": Invalid byte 1 of 1-byte UTF-8 sequence.
Invalid byte 1 of 1-byte UTF-8 sequence.
[2010-02-09 16:59:19,714] INFO: Loading file:/home/misha/personal/ProgramD/aiml/chomskyAIML/chomsky064.aiml....
[2010-02-09 16:59:19,727] INFO: Loading file:/home/misha/personal/ProgramD/aiml/chomskyAIML/chomsky057.aiml....
[2010-02-09 16:59:19,730] WARN: Error parsing "file:/home/misha/personal/ProgramD/aiml/chomskyAIML/chomsky057.aiml": Element or attribute do not match QName production: QName::=(NCName':')?NCName.
Element or attribute do not match QName production: QName::=(NCName':')?NCName.
[2010-02-09 16:59:19,731] INFO: Loading file:/home/misha/personal/ProgramD/aiml/chomskyAIML/update039.aiml....
[2010-02-09 16:59:19,732] WARN: Error parsing "file:/home/misha/personal/ProgramD/aiml/chomskyAIML/update039.aiml": cvc-complex-type.2.4.b: The content of element 'aiml' is not complete. One of '{"http://alicebot.org/2001/AIML-1.0.1":topic, "http://alicebot.org/2001/AIML-1.0.1":category}' is expected.
cvc-complex-type.2.4.b: The content of element 'aiml' is not complete. One of '{"http://alicebot.org/2001/AIML-1.0.1":topic, "http://alicebot.org/2001/AIML-1.0.1":category}' is expected.
[2010-02-09 16:59:19,739] INFO: Loading file:/home/misha/personal/ProgramD/aiml/chomskyAIML/chomsky025.aiml....
[2010-02-09 16:59:19,742] INFO: Loading file:/home/misha/personal/ProgramD/aiml/chomskyAIML/update001.aiml....
[2010-02-09 16:59:19,744] WARN: Error parsing "file:/home/misha/personal/ProgramD/aiml/chomskyAIML/update001.aiml": Invalid byte 1 of 1-byte UTF-8 sequence.
Invalid byte 1 of 1-byte UTF-8 sequence.
I am thinking the problem might be that I am using an AIML 1.0.1 heading, but need an AIML 1.0 one. Any advice? Am I on the right track?
Thank you
Misha
p.s. If curious, here is the Java code I am using for conversation conversion so far. Is this a good way to go? Any big picture ideas for me? Thank you!
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.List;
import java.util.LinkedList;
import java.io.FileNotFoundException;
import java.net.URL;
import java.io.IOException;
import java.io.File;
import java.io.FileInputStream;
import java.io.BufferedInputStream;
import org.aitools.programd.Core;
import org.aitools.programd.util.URLTools;
public class test
{
// http://joust.kano.net/weblog/archives/000060.html
private static final Pattern wrapRE=Pattern.compile(".{0,79}(?:\\S(?:-| |$)|$)");
private static String[] wordWrap(String str) {
List list = new LinkedList();
Matcher m = wrapRE.matcher(str);
while (m.find()) list.add(m.group());
return (String[]) list.toArray(new String[list.size()]);
}
private static void outputWrapped(String str, String prefix) {
String[] wrapped=wordWrap(str);
for (int j=0;j<wrapped.length;j++) {
System.out.println(prefix+wrapped[j]);
}
}
private static void outputWrapped(String str) {
outputWrapped(str, "");
}
public static void main(String[] argv) throws FileNotFoundException,IOException {
URL baseURL = URLTools.createValidURL(System.getProperty("user.dir"));
Core core = new Core(baseURL, URLTools.createValidURL("/home/misha/personal/ProgramD/conf/core.xml"));
// Send the connect string.
core.processResponse(core.getSettings().getConnectString());
byte[] buffer = new byte[(int) new File("message").length()];
BufferedInputStream f = new BufferedInputStream(new FileInputStream("message"));
f.read(buffer);
String message=new String(buffer);
String botid=core.getBots().getABot().getID();
String userid="misha";
String patternStr = "(?<=(\r\n|\r|\n))([ \\t]*$)+"; // http://www.exampledepot.com/egs/java.util.regex/parsepara.html
String[] paragraph = Pattern.compile(patternStr, Pattern.MULTILINE).split(message);
for (int i=0;i<paragraph.length;i++) {
String[] sentence=paragraph[i].split("[?!.]\\s*");
String response="";
for (int j=0;j<sentence.length;j++) {
String r=core.getResponse(sentence[j],userid,botid).replaceAll("\\s+"," ");
if (r!=null&r.length()>0) {
if (response.length()==0) {
response=r.trim();
} else {
response=response+" "+r.trim();
}
}
}
outputWrapped(paragraph[i],"> ");
outputWrapped(response);
}
}
}