Automated email response system

  • 1 Replies
  • 4171 Views
*

misha680

  • Roomba
  • *
  • 1
Automated email response system
« on: February 09, 2010, 11:43:35 pm »
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
Code
<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_D

and 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-set

I have even tried the updated one:
http://www.aimlpad.com/chomskyaiml.zip

No luck. I am using this script to convert:
Code
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:
Code
[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!

Code
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);
}
    }
}

*

Freddy

  • Administrator
  • **********************
  • Colossus
  • *
  • 6832
  • Mostly Harmless
Re: Automated email response system
« Reply #1 on: February 10, 2010, 11:37:02 am »
Hi Misha welcome to the forum.

Please do not triple post like you have done, or even double post.  You only need to post once in a relevant section to attract attention - most members read every post that is made because we run at a steady pace here.  If it runs unanswered for a few days then feel free to bump it up to the list of recent posts.

Since this query is to do with AIML interpreters I have left this one in the AIML section.  There are a few programmers here with experience in Java.  Personally I don't, so cant help.

If you don't get any response then I would try over on AI Nexus

Many thanks  :)


 


Useful new robot.
by MagnusWootton (Robotics News)
January 15, 2022, 01:50:10 am
Christmas Eve Launch
by frankinstien (Robotics News)
January 13, 2022, 08:08:13 am
Forest - The Show
by Zero (Robotics News)
January 09, 2022, 01:58:03 pm
I wonder how well GPT-3 will on run this.
by frankinstien (AI News )
December 20, 2021, 04:36:39 am

Users Online

92 Guests, 0 Users

Most Online Today: 97. Most Online Ever: 2369 (November 21, 2020, 04:08:13 pm)

Articles