无法通过Python在AIML中加载模式

时间:2016-07-06 12:49:47

标签: python aiml

我已经通过pip安装了AIML并编写了文件 startup.py std-startup.xml basic.aiml 核心文件夹中的 bot_brain.brn 。当我尝试运行 startup.py 时,我收到此警告:

val seq = Seq(("foo", "bar3"), ("foo", "bar1"), ("foo", "bar2"))
seq.groupBy(_._1)
  .mapValues(_.map(_._2))

这是 std-startup.xml 的内容:

Loading std-startup.xml... done (0.06 seconds)
WARNING: No match found for input: load aiml b

Kernel bootstrap completed in 0.10 seconds
Saving brain to core/bot_brain.brn... done (0.00 seconds)

这是Python脚本:

<aiml version="1.0.1" encoding="UTF-8">
    <!-- std-startup.xml -->

    <category>
        <pattern>load aiml b</pattern>
        <template>
            <learn>basic.aiml</learn>
        </template>
    </category>

</aiml>

对于每个输入,我都会收到错误import aiml import os kernel = aiml.Kernel() if os.path.isfile("core/bot_brain.brn"): kernel.bootstrap(brainFile = "core/bot_brain.brn") else: kernel.bootstrap(learnFiles = "std-startup.xml", commands = "load aiml b") kernel.saveBrain("core/bot_brain.brn") while True: msg = raw_input(">") if msg == "exit": exit(0) elif msg == "save": kernel.saveBrain("core/bot_brain.brn") else: bot_response = kernel.respond(msg) print("bot: " + bot_response) 。我做错了什么?除了 bot_brain.brn

之外,所有内容都在同一目录中

1 个答案:

答案 0 :(得分:0)

问题解决了;我不得不用大写字母输入它:

<category>
    <pattern>LOAD AIML B</pattern>
    <template>
        <learn>basic.aiml</learn>
    </template>
</category>