1

I am trying to load AIML file by Pyaiml(python2.7 and pyaiml 0.8.6) in windows 8.1 platform.

Here is my code:

__author__ = 'MASOUD AMR'
import aiml
import xml
mybot = aiml.Kernel()
mybot.learn('D:\\Python\\chatbot\\lab.xml')
mybot.respond("what is your name")

And the AIML file I am using (lab.xml) is:

<?xml version="1.0" encoding="utf-8"?>

<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">

<category>
        <pattern>*</pattern>
    <template>Hello,   I'm glad to see you</template>
</category>

<category>
        <pattern>WHAT IS YOUR NAME</pattern>
        <template>My name is <bot name="name"></bot></template>
</category>

</aiml>

It keeps showing this error and I don't know why. The error:

Connected to pydev debugger (build 139.487)
Loading D:\Python\chatbot\lab.xml...
FATAL PARSE ERROR in file D:\Python\chatbot\lab.xml:
D:\Python\chatbot\lab.xml:2:0: XML or text declaration not at start of entity
WARNING: No match found for input: what is your name
Masoud AMR
  • 134
  • 2
  • 17
  • 1
    You can take a look at this [http://stackoverflow.com/questions/15351472/pyaiml-not-loading-startup?rq=1]. – Freelancer Dec 28 '14 at 12:27

1 Answers1

0

I found a bug in my code. My XML code declaration did not start from the beginning of document(the first line). XML declaration is allowed only at the start of the document.

As you can see the Pycharm IDE even shows error:

enter image description here

Freelancer
  • 836
  • 1
  • 14
  • 47
Masoud AMR
  • 134
  • 2
  • 17