Python Package for Chatbot
from sen_chatbot.ChatBot import ChatBot
cb = ChatBot()
cb.reply('hi')
'Hi there'
cb.quickReply('hi')
'Hello'
In case of reply(argument) when any of the input strings is found to be a subset of the given argument then it will consider it and show anyone of the matching results randomly. In case of quickReply(argument) it will only show the result which is fully matching with the given argument and it returns a response immediately once it finds a match.
input_list = ['new user','do not have account']
output_list = ['register','create one!']
cb.addData(input_list,output_list)
cb.reply('new user')
'register'
If any of the inputs matches with the argument of reply(argument) function then it returns a response among the outputs randomly.
data = {'1':{'input':['hi','hello'],'output':['hello']},'2':{'input':['bye'],'output':['goodbye','tata']}}
cb.setData(data)
cb.showData()
{'1': {'input': ['hi', 'hello'], 'output': ['hello']}, '2': {'input': ['bye'], 'output': ['goodbye', 'tata']}}
cb.quickReply('bye')
'tata'
In case of adding or setting data try to keep the proper format. Previously some data is set for basic use but we can customize it according to our needs.
cb.showData()
{'1': {'input': ['hi', 'hello'], 'output': ['hello', 'hi there']}, '2': {'input': ['bye'], 'output': ['goodbye', 'tata']}}
cb.reply('Sourav Ganguly')
'Sourav Chandidas Ganguly ( (listen); born 8 July 1972), affectionately known as Dada (meaning "elder brother" in Bengali), is an Indian former cricketer, commentator and administrator who played as a left-handed opening batsman and was captain of the Indian national team. He is the 39th and current president of the Board of Control for Cricket in India and President of the Editorial Board with Wisden India...
It shows wikipedia results as a default output and by default wikipedia feature is enabled. If you want to disable it you can do it this way.
cb.enableWikipedia(False)
cb.reply('Sourav Ganguly')
'Try something else...'
cb.quickReply('Sourav Ganguly')
"I am sorry! I did't understand you"
cb.authorName()
'Sourav Sen'
cb.authorEmail()