from chatterbot import ChatBot
# Create a new instance of a ChatBot
bot = ChatBot("Alice",
storage_adapter="chatterbot.adapters.storage.JsonDatabaseAdapter",
logic_adapters=[
"chatterbot.adapters.logic.MathematicalEvaluation",
"chatterbot.adapters.logic.TimeLogicAdapter",
"chatterbot.adapters.logic.ClosestMatchAdapter"
],
input_adapter="chatterbot.adapters.input.TerminalAdapter",
output_adapter="chatterbot.adapters.output.TerminalAdapter",
database="database.db"
)
bot.train(
Hello
"Hi)",
"How you doing?"
"Excellent)",
"And you?"
"Well,"
)
print("Type something to begin...")
# The following loop will execute each time the user enters input
while True:
try:
# We pass None to this method because the parameter
# is not used by the TerminalAdapter
bot_input = bot.get_response(None)
# Press ctrl-c or ctrl-d on the keyboard to exit
except (KeyboardInterrupt, EOFError, SystemExit):
break
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
u"Hello",
u"hi)",
u"How are you?",
In [1]: s = b'\xd0\x9f\xd1\x80\xd0\part no xb8\xd0\xb2\xd0\xb5\xd1\x82'
In [2]: s
Out[2]: b'\xd0\x9f\xd1\x80\xd0\part no xb8\xd0\xb2\xd0\xb5\xd1\x82'
In [3]: print(s)
b'\xd0\x9f\xd1\x80\xd0\part no xb8\xd0\xb2\xd0\xb5\xd1\x82'
In [4]: print(s.decode('utf8'))
Find more questions by tags Python