我正在建造一个聊天机器人。我每次运行这个程序时,如何阻止它被训练?
我的节目:
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
chatbot = ChatBot('Adithyan AK')
trainer = ChatterBotCorpusTrainer(chatbot)
trainer.train("chatterbot.corpus.english")
trainer.train("chatterbot.corpus.english.greetings")
trainer.train("chatterbot.corpus.english.conversations")
while(True):
query = input("You : ")
response = chatbot.get_response(query)
print(response)每次运行上述程序时,我都会收到下面的日志消息。
[nltk_data] Downloading package stopwords to /root/nltk_data...
[nltk_data] Package stopwords is already up-to-date!
[nltk_data] Downloading package averaged_perceptron_tagger to
[nltk_data] /root/nltk_data...
[nltk_data] Package averaged_perceptron_tagger is already up-to-
[nltk_data] date!
/usr/local/lib/python3.7/dist-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)
Training ai.yml: [####################] 100%
Training botprofile.yml: [####################] 100%
Training computers.yml: [####################] 100%
Training conversations.yml: [####################] 100%
Training emotion.yml: [####################] 100%
Training food.yml: [####################] 100%
Training gossip.yml: [####################] 100%
Training greetings.yml: [####################] 100%
Training health.yml: [####################] 100%
Training history.yml: [####################] 100%
Training humor.yml: [####################] 100%
Training literature.yml: [####################] 100%
Training money.yml: [####################] 100%
Training movies.yml: [####################] 100%
Training politics.yml: [####################] 100%
Training psychology.yml: [####################] 100%
Training science.yml: [####################] 100%
Training sports.yml: [####################] 100%
Training trivia.yml: [####################] 100%
Training greetings.yml: [####################] 100%
Training conversations.yml: [####################] 100%发布于 2021-01-17 23:55:52
放松,先训练和腌制机器人。在你的主程序中,解开受过训练的机器人,抑制伐木,然后离开。
发布于 2021-01-24 08:24:00
当我尝试将聊天机器人添加到我的测试网站时,我也遇到了类似的问题。我的解决方案可能不是你想要的,但我把它放在这里。
这是一些密码。
train_bot/bot.py (字面意思是取自聊天机器人文档)。
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
# Create a new instance of a ChatBot
bot = ChatBot(
'train',
storage_adapter='chatterbot.storage.SQLStorageAdapter',
logic_adapters=[
{
'import_path': 'chatterbot.logic.BestMatch',
'default_response': 'I am sorry, but I do not understand.',
'maximum_similarity_threshold': 0.90
}
],
database_uri='sqlite:///database-chatbot.db'
)
# Create a new trainer for the chatbot
trainer = ChatterBotCorpusTrainer(bot)
# Train the chatbot based on the english corpus
trainer.train("chatterbot.corpus.english")
print('Type something to begin...')
if __name__ =='__main__':
# The following loop will execute each time the user enters input
while True:
try:
user_input = input()
bot_response = bot.get_response(user_input)
print(bot_response)
# Press ctrl-c or ctrl-d on the keyboard to exit
except (KeyboardInterrupt, EOFError, SystemExit):
breakview.py
alice = ChatBot(
'Alice',
storage_adapter='chatterbot.storage.SQLStorageAdapter',
logic_adapters=[
{
'import_path': 'chatterbot.logic.BestMatch',
'default_response': 'I am sorry, but I do not understand.',
'maximum_similarity_threshold': 0.90
}
],
database_uri='sqlite:///train_bot/database-chatbot.db' #this is the same URI for the previously trained bot
)现在它如预期的那样起作用了。
发布于 2021-05-23 11:24:52
现在有点晚了,但是快速查看代码就会发现,培训师使用了一个kwarg show_training_progress,您可以将它设置为False来阻止日志的打印。
就像这样:
trainer = ChatterBotCorpusTrainer(bot, show_training_progress=False)https://stackoverflow.com/questions/60056237
复制相似问题