本文整理汇总了Python中chatterbot.trainers.ListTrainer方法的典型用法代码示例。如果您正苦于以下问题:Python trainers.ListTrainer方法的具体用法?Python trainers.ListTrainer怎么用?Python trainers.ListTrainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类chatterbot.trainers
的用法示例。
在下文中一共展示了trainers.ListTrainer方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: tariner
# 需要导入模块: from chatterbot import trainers [as 别名]
# 或者: from chatterbot.trainers import ListTrainer [as 别名]
def tariner(asay):
momo.set_trainer(ListTrainer)
while True:
conv = []
conv.append(asay)
bsay = B(asay)
conv.append(bsay)
momo.train(conv)
print(conv)
conv = []
conv.append(bsay)
asay = A(bsay)
conv.append(asay)
momo.train(conv)
print(conv)
sleep(5) # 控制频率
示例2: setUp
# 需要导入模块: from chatterbot import trainers [as 别名]
# 或者: from chatterbot.trainers import ListTrainer [as 别名]
def setUp(self):
super().setUp()
self.chatbot.logic_adapters = [
DummyMutatorLogicAdapter(self.chatbot)
]
self.trainer = ListTrainer(
self.chatbot,
show_training_progress=False
)
self.trainer.train([
'Hello',
'How are you?'
])
示例3: __init__
# 需要导入模块: from chatterbot import trainers [as 别名]
# 或者: from chatterbot.trainers import ListTrainer [as 别名]
def __init__(self, bot):
self.bot = bot
self.settings = dataIO.load_json("data/chatterbot/settings.json")
self.log = dataIO.load_json("data/chatterbot/log.json")
self.chatbot = chatterbot.ChatBot("redbot",
storage_adapter="chatterbot.storage.MongoDatabaseAdapter",
# database="data/chatterbot/db",
logic_adapters=[
"chatterbot.logic.BestMatch",
"chatterbot.logic.TimeLogicAdapter",
"chatterbot.logic.MathematicalEvaluation"]
)
self.chatbot.set_trainer(ListTrainer)
示例4: setup
# 需要导入模块: from chatterbot import trainers [as 别名]
# 或者: from chatterbot.trainers import ListTrainer [as 别名]
def setup(bot):
check_folders()
check_files()
if not chatt:
bot.pip_install("chatterbot")
import chatterbot
from chatterbot.trainers import ListTrainer
bot.add_cog(Chatterbot(bot))
示例5: train
# 需要导入模块: from chatterbot import trainers [as 别名]
# 或者: from chatterbot.trainers import ListTrainer [as 别名]
def train(name, data):
bot = getBot(name)
bot.set_trainer(ListTrainer)
bot.train(data)
示例6: set_momo_answer
# 需要导入模块: from chatterbot import trainers [as 别名]
# 或者: from chatterbot.trainers import ListTrainer [as 别名]
def set_momo_answer(conversation):
momo_chat.set_trainer(ListTrainer)
momo_chat.train(conversation)
示例7: get_list_trainer
# 需要导入模块: from chatterbot import trainers [as 别名]
# 或者: from chatterbot.trainers import ListTrainer [as 别名]
def get_list_trainer(chatbot):
return ListTrainer(
chatbot,
show_training_progress=False
)
示例8: test_filter_selection
# 需要导入模块: from chatterbot import trainers [as 别名]
# 或者: from chatterbot.trainers import ListTrainer [as 别名]
def test_filter_selection(self):
"""
Test that repetitive responses are filtered out of the results.
"""
from chatterbot.conversation import Statement
from chatterbot.trainers import ListTrainer
self.chatbot.filters = (filters.get_recent_repeated_responses, )
self.trainer = ListTrainer(
self.chatbot,
show_training_progress=False
)
self.trainer.train([
'Hi',
'Hello',
'Hi',
'Hello',
'Hi',
'Hello',
'How are you?',
'I am good',
'Glad to hear',
'How are you?'
])
statement = Statement(text='Hello', conversation='training')
first_response = self.chatbot.get_response(statement)
second_response = self.chatbot.get_response(statement)
self.assertEqual('How are you?', first_response.text)
self.assertEqual('Hi', second_response.text)
示例9: setUp
# 需要导入模块: from chatterbot import trainers [as 别名]
# 或者: from chatterbot.trainers import ListTrainer [as 别名]
def setUp(self):
super().setUp()
self.trainer = ListTrainer(
self.chatbot,
show_training_progress=False
)
示例10: __init__
# 需要导入模块: from chatterbot import trainers [as 别名]
# 或者: from chatterbot.trainers import ListTrainer [as 别名]
def __init__(self, bot):
self.bot = bot
default_guild = {
"auto_train": False,
"blacklist": [],
"whitelist": [],
"auto_response": False,
}
default_channel = {"message": None, "author": None}
self.config = Config.get_conf(self, 218773382617890828)
self.config.register_guild(**default_guild)
self.config.register_channel(**default_channel)
# https://github.com/bobloy/Fox-V3/blob/master/chatter/chat.py
path = cog_data_path(self)
data_path = path / "database.sqlite3"
self.chatbot = ChatBot(
"ChatterBot",
storage_adapter="chatterbot.storage.SQLStorageAdapter",
database=str(data_path),
statement_comparison_function=levenshtein_distance,
response_selection_method=get_first_response,
logic_adapters=[
{"import_path": "chatterbot.logic.BestMatch", "default_response": ":thinking:"}
],
)
self.trainer = ListTrainer(self.chatbot)