使grokitbot在本地工作

时间:2015-02-15 04:01:52

标签: python aiml

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

Grokitbot被连接起来直接与使用twisted的irc服务器对话。

查看源代码,似乎Grokitbot.py完成了所有的irc工作,而AIMLBot.py完成了所有实际的工作,所以我放弃了以前的文件。 This is 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机器。

1 个答案:

答案 0 :(得分: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

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

如果它还没有工作,你可以给我们输出脚本吗?你看到错误了吗?它有相同的输出线吗? ("正在加载..."," [猜猜]"等)。