Making a ChatBot in python using NLTK
A chatbot is a smart application that reduces human work and helps an organization to solve basic queries of the customer. Today most of the companies, business from different sector makes use of chatbot in a different way to reply their customer as fast as possible. chatbots also help in increasing traffic of site which is top reason of business to use chatbots.
Chatbot asks for basic information of customers like name, email address, and the query. If a query is simple like product fault, booking mistake, need some information then without any human connection it can solve it automatically and If some problem is high then It passes the details to the human head and helps customer to connect with organization manager easily. And most of the customers like to deal and talk with a chatbot.
Source Code:
def greet(bot_name, birth_year): print 'Hello! My name is {0}.'.format(bot_name) print 'I was created in {0}.'.format(birth_year) def remind_name(): print 'Please, remind me your name.' name = input() print 'What a great name you have, {0}!'.format(name) def guess_age(): print 'Let me guess your age.' print 'Enter remainders of dividing your age by 3, 5 and 7.' rem3 = int(input()) rem5 = int(input()) rem7 = int(input()) age = (rem3 * 70 + rem5 * 21 + rem7 * 15) % 105 print "Your age is {0}; that's a good time to start programming!".format(age) def count(): print 'Now I will prove to you that I can count to any number you want.' num = int(input()) counter = 0 while counter <= num: print '{0} !'.format(counter) counter += 1 def test(): print "Let's test your programming knowledge." print 'Why do we use methods?' print '1. To repeat a statement multiple times.' print '2. To decompose a program into several small subroutines.' print '3. To determine the execution time of a program.' print '4. To interrupt the execution of a program.' answer = 2 guess = int(input()) while guess != answer: print 'Please, try again.' guess = int(input()) print 'Completed, have a nice day!' print '.................................' print '.................................' print '.................................' def end(): print 'Congratulations, have a nice day!' print '.................................' print '.................................' print '.................................' input() greet('ChatBot', '2022') remind_name() guess_age() count() test() end()
Comments
Post a Comment