0

我想设置 grokitbot 通过终端与用户在本地聊天。

Grokitbot 连接到使用 twisted 直接与 irc 服务器对话。

查看源代码,似乎 Grokitbot.py 完成了所有 irc 的工作,而 AIMLBot.py 完成了所有实际工作,所以我放弃了以前的文件。 这是 AIMLBot.py

还有一个名为AIMLBayes.py的脚本可以完成所有贝叶斯的工作。

在我的第一个问题中,我运行的代码没有作为名称发送的字符串。因此无法创建培训文件。

所以,改写我原来的问题:

from AIMLBot import AIMLBot

bot = AIMLBot("Joe")

while True:
    line = raw_input()
    print bot.on_MSG_IN("netanel", line)

这是脚本中的日志:

Loading data/aiml/startup.xml... done (0.11 seconds)
Loading data/aiml\example.aiml... done (0.01 seconds)
Loading data/aiml\goodbye.aiml... done (0.00 seconds)
Loading data/aiml\hello.aiml... done (0.01 seconds)
Loading data/aiml\main.aiml... done (0.01 seconds)
Loading data/aiml\thanks.aiml... done (0.00 seconds)
Loading data/aiml\tools.aiml... done (0.01 seconds)
Loading data/aiml\unknown.aiml... done (0.00 seconds)
Interpreter Version Info: PyAIML 0.8.6
Kernel bootstrap completed in 0.18 seconds
[Alert] Failed to load bayesian brain - Joe.bay, creating it now
hello
Loading data/aiml/training/netanel.aiml... done (0.00 seconds)
Sorry, I don't understand. What do you mean?
hello
[Handler] TRAINING
Failed to learn
OK, I grok that

此代码在 Windows 上失败。但是相同的代码可以在运行 Debian 的 Linux 机器上运行。

4

1 回答 1

0

看起来您需要为以下内容提供名称而不是空字符串on_MSG_IN

    print a.on_MSG_IN("steve", line)

进行更改后,它对我有用:

$ ../bin/python bot.py
Loading data/aiml/startup.xml... done (0.03 seconds)
Loading data/aiml/example.aiml... done (0.00 seconds)
Loading data/aiml/goodbye.aiml... done (0.00 seconds)
Loading data/aiml/hello.aiml... done (0.00 seconds)
Loading data/aiml/main.aiml... done (0.00 seconds)
Loading data/aiml/thanks.aiml... done (0.00 seconds)
Loading data/aiml/tools.aiml... done (0.00 seconds)
Loading data/aiml/unknown.aiml... done (0.00 seconds)
Interpreter Version Info: PyAIML 0.8.6
Kernel bootstrap completed in 0.03 seconds
[Bayes] Brain loaded ok
hi
[Guess] hello
[Topic] hello
Hallo Pooh
greetings
Loading data/aiml/training/steve.aiml... done (0.00 seconds)
Sorry, I don't understand. What do you mean?
hello
[Guess] hello
[Handler] TRAINING
OK, I grok that
greetings
[Guess] hello
[Topic] hello
Hello steve

我刚刚教它“问候”是另一种打招呼的方式。

如果它仍然不起作用,你能给我们脚本的输出吗?你看到错误了吗?它是否具有与我相同的输出线?(“加载中...”、“[猜测]”等)。

于 2015-02-15T05:55:15.923 回答