首页 > 解决方案 > ChatterBot 没有接受过 ubuntu 语料库的训练

问题描述

我按照这个例子用 Ubuntu 语料库训练我的聊天机器人

我的代码是下一个:

# import ChatBot
from chatterbot import ChatBot
# import Trainer
from chatterbot.trainers import UbuntuCorpusTrainer

# Declare a bot
bot = ChatBot('Zeus')

# Training
trainer3 = UbuntuCorpusTrainer(bot)
# Start by training our bot with the Ubuntu corpus data
trainer3.train()

# Get a response to an input statement
bot.get_response("Hello, how are you today?")

while True:
    # Input from user
    message = input('You: ')
    # if message is not "Bye"
    if message.strip() != 'Bye':
        reply = bot.get_response(message)
        print('Zeus:', reply)
        # if message is "Bye"
    if message.strip() == 'Bye':
        print('Zeus: Bye')
        break

输出显示该机器人未使用 ubuntu 语料库进行训练:

/usr/local/bin/python3.7 /home/user/Documents/python-workspace/zeus_bot/UbuntuCorpus.py
[nltk_data] Downloading package averaged_perceptron_tagger to
[nltk_data]     /home/user/nltk_data...
[nltk_data]   Package averaged_perceptron_tagger is already up-to-
[nltk_data]       date!
[nltk_data] Downloading package stopwords to /home/user/nltk_data...
[nltk_data]   Package stopwords is already up-to-date!
Training took 0.11888790130615234 seconds.
/usr/local/lib/python3.7/site-packages/chatterbot/corpus.py:38: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
  return yaml.load(data_file)
You: Hi
Zeus: Hello, how are you today?
You: very well
Zeus: Hi
You: what news?
Zeus: Hello, how are you today?
You: i am fine
Zeus: Hi
You: Bye
Zeus: Bye

Process finished with exit code 0

它没有显示训练的加载过程。当我与机器人聊天时,我只得到 get 响应,没有别的。

标签: python-3.xubuntucorpuschatterbot

解决方案


推荐阅读