How to use the chatterbot.trainers.ListTrainer function in ChatterBot

To help you get started, we’ve selected a few ChatterBot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gunthercox / ChatterBot / tests / test_benchmarks.py View on Github external
def get_list_trainer(chatbot):
    return ListTrainer(
        chatbot,
        show_training_progress=False
    )
github gunthercox / ChatterBot / tests / training / test_database_export.py View on Github external
def setUp(self):
        super().setUp()
        self.trainer = ListTrainer(
            self.chatbot,
            show_training_progress=False
        )
github gunthercox / ChatterBot / tests / logic / best_match_integration_tests / test_sentiment_comparison.py View on Github external
def setUp(self):
        super().setUp()
        from chatterbot.trainers import ListTrainer
        from chatterbot.comparisons import sentiment_comparison

        self.trainer = ListTrainer(
            self.chatbot,
            show_training_progress=False
        )

        self.adapter = BestMatch(
            self.chatbot,
            statement_comparison_function=sentiment_comparison
        )
github jim-schwoebel / voicebook / chapter_5_generation / make_vchatbot.py View on Github external
return transcript 

def speak_text(text):
    engine = pyttsx3.init()
    engine.say(text)
    engine.runAndWait()

# works on Drupal FAQ forms
page=requests.get('http://cyberlaunch.vc/faq-page')
soup=BeautifulSoup(page.content, 'lxml')
g=soup.find_all(class_="faq-question-answer")
y=list()

# initialize chatbot parameters 
chatbot = ChatBot("CyberLaunch")
chatbot.set_trainer(ListTrainer)

# parse through soup and get Q&A 
for i in range(len(g)):
    entry=g[i].get_text().replace('\xa0','').split('  \n\n')
    newentry=list()
    for j in range(len(entry)):
        if j==0:
            qa=entry[j].replace('\n','')
            newentry.append(qa)
        else:
            qa=entry[j].replace('\n',' ').replace('   ','')
            newentry.append(qa)
        
    y.append(newentry)

# train chatbot with Q&A training corpus 
github CodeLabClub / codelab_adapter_extensions / extensions / extension_chatterbot.py View on Github external
def init_chatbot(self):

        self.deepThought = ChatBot("deepThought", read_only=True)
        self.deepThought.set_trainer(ListTrainer)
        self.deepThought.train([
            "action",
            "嗳,渡边君,真喜欢我?",
            "那还用说",
            "那么,可依得我两件事?",
            "三件也依得",
        ])
github TrustyJAID / Trusty-cogs / chatter / chatter.py View on Github external
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)
github gunthercox / ChatterBot / examples / default_response_example.py View on Github external
# Create a new instance of a ChatBot
bot = ChatBot(
    'Example Bot',
    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
        }
    ]
)

trainer = ListTrainer(bot)

# Train the chat bot with a few responses
trainer.train([
    'How can I help you?',
    'I want to create a chat bot',
    'Have you read the documentation?',
    'No, I have not',
    'This should help get you started: http://chatterbot.rtfd.org/en/latest/quickstart.html'
])

# Get a response for some unexpected input
response = bot.get_response('How do I make an omelette?')
print(response)
github Guepardo / Alex_Chatbot / kernel / brain_train.py View on Github external
def train_by_data_from_database(cls): 
		cls.set_trainer(ListTrainer)

		db = Database()
		cur = db.get_cursor()

		query = """SELECT msg, replay_to_id FROM messages WHERE replay_to_id IS NOT NULL order by id desc"""
		result = db.execute(query)
		count = 0
		for row in result:
			count += 1 
			answer = row[0]
			query = """SELECT msg FROM messages WHERE telegram_id = {replay_to_id}""".format(replay_to_id=row[1])
			temp = db.execute(query)
			
			if len(temp) > 0: 
				statement = temp[0][0]
				data_set = [unicode(statement.replace('\n','').strip(), errors='replace'), unicode(answer.replace('\n','').strip(), errors='replace')]
github tech-quantum / sia-cog / bot / chatbot.py View on Github external
def train(name, data):
    bot = getBot(name)
    bot.set_trainer(ListTrainer)
    bot.train(data)