Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- #
- # Dictionnary based Eliza type program
- # that will emulate a call-centre agent named Bob
- # http://www.peileppe.com
- # ======================================================================
- # Monday 03 March 2014 [11:30]
- #
- dict1= {
- " hello " : ['What seems to be the problem, sir?','How may I help, sir', 'How are you, sir?'],
- " bye ":['Thanks for calling call-centre Grinder support','Thanks for calling the help-line','Thanks for your call, sir'],
- " how ":['good question','I don\'t know, I will have to transfer this to the customer service department','Well, it\'s out of support as far as I\'m concerned'],
- " why ":['This issue has been resolved with the latest version','mmh, I don\'t know, I will have to transfer this to the customer service department','We will investigate'],
- " who ":['why do you want to know?','the name should be on the receipt','the name might be at the end of the invoice'],
- " where ":['I\'m sure you can find this information in the user manual','I don\'t know where exactly I\'m checking the FAQ','I might need to escalate this to the other team'],
- " when ":['our lines open at 7am and end at 7pm 7 days a week','We also work week-end','There is an early shift, and a late shift'],
- " name ":['Sir, we are not supposed to give you our full name','My name is Bob','Bob is my name'],
- " thank":['don\'t mention it','You\'re welcome','at your service, Sir'],
- " manager ":['My manager is not at his desk, right now - do you want me to arrange a call back?','My manager can take the call, please hold-on','Please, hold-on, Sir'],
- " could ":['is it true?','I don\'t know if that\'s possible','challenging'],
- " can ": ['is it really true?','If that\'s possible, of course','Really?'],
- " issue ":['I will need your serial number','I need to fill your caller ID','When was your last call?'],
- " problem ":['This is a common issue','Does it occurs after an update?','Is it a problem that re-appear from time to time?'],
- " must ":['I\'m not sure of that','why?','Any other options?'],
- " grinder ":['This is the Call-centre support center','That\'s us here in the Call-centre','Call-Centre Grinder, yes Sir!'],
- "_nokey_":['Can you rephrase that, please?','why would you say that?','usually, that is considered out of support']
- }
- print ("Hi, my name is Bob how may I help you?!")
- loop1=True
- previous_input='empty'
- answer_loop=0
- while loop1:
- input=raw_input("Caller: ")
- input=" "+input.replace("\"","")+" "
- while input.count(" ") >0:
- input=input.replace(" "," ")
- input=input.lower()
- if input.count("bye") or input.count("quit") or input.count("exit") > 0 :
- print "Okay, talk to you later ..."
- loop1=False
- break
- elif input==previous_input:
- print "You already said that"
- else:
- keyword="_nokey_"
- for k in dict1:
- if k in input:
- keyword=k
- break
- print "Bob: "+dict1[keyword][answer_loop]
- answer_loop+=1
- if answer_loop > 2:
- answer_loop=0
- previous_input=input
Advertisement
Add Comment
Please, Sign In to add comment