【问题标题】:Error Loading the AIML file in pyaiml在 pyaiml 中加载 AIML 文件时出错
【发布时间】:2014-12-27 22:23:52
【问题描述】:

我正在尝试在windows 8.1 平台上通过 Pyaiml(python2.7 和 pyaiml 0.8.6)加载AIML 文件。

这是我的代码:

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

我正在使用的AIML 文件(lab.xml)是:

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

它一直显示这个错误,我不知道为什么。 错误:

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

【问题讨论】:

标签: python xml aiml


【解决方案1】:

我在我的代码中发现了一个错误。 我的 XML 代码声明不是从文档开头(第一行)开始的。 XML 声明只允许在文档的开头。

如您所见,Pycharm IDE 甚至显示错误:

【讨论】:

    猜你喜欢
    • 2018-01-16
    • 1970-01-01
    • 2014-10-31
    • 1970-01-01
    • 2018-10-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-30
    相关资源
    最近更新 更多