ChatterBot 未使用 ubuntu 语料库进行训练

问题描述 投票:0回答:1

我按照这个例子使用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.x ubuntu corpus chatterbot
1个回答
0
投票

Ubuntu训练器没有问题。问题是它尝试一次从 25,000 多个 TSV 文件创建 ChatterBot DB!根据我的测试计算,这可能需要 12 到 15 个小时!此外,它们没有显示该过程的进度,甚至没有显示任何需要等待很长时间的信息。只有白痴才能分发这样的模块。

嗯,我创建了一个脚本,该脚本可以从 Ubuntu 对话框 TGZ 中包含的一系列 TSV 文件创建 ChatterBot DB,该脚本可以非常快,具体取决于您选择要处理的 TSV 文件的数量。另请注意,数据库的大小可能非常大。承载整个包的 DB 大约有 500 MB! (当然我没有尝试创造这样的怪物。但我想与它的互动会很有成果!🙂

对于任何有兴趣并且可以使用 Python 编程的人,可以在“chatterbot”包的“trainers.py”中找到 UbuntuCorpusTrainer 类。您可以将其调整为使用特定的 TSV 文件列表,而不是创建存储在默认目录“dialogs”中的所有 TSV 文件的巨大列表。(在我的例子中,这是“C:\Users{username}\ubuntu_data\”) ubuntu_dialogs\dialogs'。)正如我所说,一个过程没有结束!

对于任何有兴趣的人,我可以提供基本代码。处理。另请注意,数据库的大小可能非常大。承载整个包的 DB 大约有 500 MB! (当然我没有尝试创造这样的怪物。但我想与它的互动会很有趣!)

对于任何有兴趣并且可以使用 Python 编程的人,可以在“chatterbot”包的“trainers.py”中找到 UbuntuCorpusTrainer 类。您可以将其调整为使用特定的 TSV 文件列表,而不是创建存储在默认目录“dialogs”中的所有 TSV 文件的巨大列表。(在我的例子中,这是“C:\Users{username}\ubuntu_data\”) ubuntu_dialogs\dialogs'。)正如我所说,一个过程没有结束!

对于任何有兴趣的人,我可以提供基本代码。

© www.soinside.com 2019 - 2024. All rights reserved.