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 に答える