【问题标题】:making grokitbot to work locally让 grokitbot 在本地工作
【发布时间】:2015-02-15 04:01:51
【问题描述】:

我想设置 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 机器上运行。

【问题讨论】:

  • 顺便说一句,我尝试在 AIML 文件夹中插入一个 std-hello.aiml 文件,它成功启动它,并且可以使用 AIML 文件中指定的命令进行响应。但是,机器人仍然不会学习新的短语。该模块带有一个 hello.aiml,但是当我加载默认的 AIML 文件时我没有得到任何响应。

标签: python aiml


【解决方案1】:

看来您需要为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

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

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

【讨论】:

  • 这似乎在 linux 上可以正常工作,但在 windows 上我仍然遇到错误。这是来自 linux 机器的日志,(我已经切断了加载目标)内核引导程序在 0.03 秒内完成 [警报] 无法加载贝叶斯大脑 - Joe.bay,现在创建它> hello Loading data/aiml/training/netanel。目标...完成(0.00 秒) 抱歉,我不明白。你什么意思? > hello 的意思是 hello [Handler] TRAINING 好的,我猜到了 > hello [Guess] hello [Topic] hello elo 所以这显然是可行的,除了在 Windows 上不行。奇怪的是我必须训练他打招呼而你却没有?顺便说一句,谢谢!
  • 没问题!哦..我也在使用Windows(但使用cygwin for python)。您应该编辑原始问题以包含这些日志消息。你说它在windows上出现错误,错误是什么?如果它适用于一个平台而不是另一个平台,您可以尝试逐步调试 (python -m pdb bot.py) 看看有什么不同。或者,由于该程序似乎非常依赖这些 *.aiml 和 *.bot 文件,因此请尝试在训练之前/之后检查 linux 和 windows 上的那些文件。 Re: 训练打招呼部分,我之前可能训练过,我忘记了。我发布的那个输出是我第二次使用它。
  • 这对我来说真的不是问题。无论如何,这一切都将在 Linux 机器上运行.. 我不能做的一件事是从 AIML 文件中的处理程序运行回调函数.. 教机器人示例意味着示例,它返回一个字符串“这是一个例子”据说你可以使用这个回调来运行指定的 on_EXAMPLE() 函数here 我尝试利用它,但该函数从未被调用..
猜你喜欢
  • 2016-04-14
  • 2018-06-18
  • 2011-08-28
  • 2016-03-09
  • 1970-01-01
  • 2011-03-21
  • 1970-01-01
  • 1970-01-01
  • 2012-12-29
相关资源
最近更新 更多