26
loading...
This website collects cookies to deliver better user experience
pip3 install chatterbot
pip3 install chatterbot_corpus
pip3 install pytz
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
bot = ChatBot("bot")
bot = ChatBot(
"bot",
storage_adapter='chatterbot.storage.SQLStorageAdapter',
database_uri='sqlite:///db.sqlite3',
logic_adapters=[
'chatterbot.logic.BestMatch',
'chatterbot.logic.TimeLogicAdapter'
]
)
# Creates an instance of the trainer
lessons = ListTrainer(bot)
# Simple statements to teach the bot
lessons.train([
'Hi',
'Hello',
'Good Morning',
'Good Morning',
'I need to ask a question about my order',
'Please, Can i have your order id',
'Ok I can see your order has been shipped',
"That's great",
'Is there anything else I can help you with',
'No thank you',
'Ok great, have a great day!',
'Thanks',
'Goodbye',
'Bye'
])
response = bot.get_response('I need to make a complaint')
print('Bot Response:', response)
import nltk
nltk download()
import nltk
import ssl
try:
_create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
pass
else:
ssl._create_default_https_context = _create_unverified_https_context
nltk.download()
# Grab Users name
name=input("Hello, I'm Bot! Please tell me your name? ")
#Start Questions
print("What is it I can help you with today " + name +" ?")
while True:
request=input(name+': ')
if request.lower() == 'bye':
print('Bot: Bye')
break
else:
response=bot.get_response(request)
print('Bot: ', response)
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
bot = ChatBot("bot")
bot = ChatBot(
"bot",
storage_adapter='chatterbot.storage.SQLStorageAdapter',
database_uri='sqlite:///db.sqlite3',
logic_adapters=[
'chatterbot.logic.BestMatch',
'chatterbot.logic.TimeLogicAdapter'
]
)
# Creates an instance of the trainer
lessons = ListTrainer(bot)
# Simple statements to teach the bot
lessons.train([
'Hi',
'Hello',
'Good Morning',
'Good Morning',
'I need to ask a question about my order',
'Please, Can i have your order id',
'Ok I can see your order has been shipped',
"That's great",
'Is there anything else I can help you with',
'No thank you',
'Ok great, have a great day!',
'Thanks',
'Goodbye',
'Bye'
])
# Grab Users name
name=input("Hello, I'm Bot! Please tell me your name? ")
#Start Questions
print("What is it I can help you with today " + name +" ?")
while True:
request=input(name+': ')
if request.lower() == 'bye':
print('Bot: Bye')
break
else:
response=bot.get_response(request)
print('Bot: ', response)