Skip to content

Commit ed96a4f

Browse files
authored
Added a Basic Chatbot program using Python (OmkarPathak#76)
1 parent 6039e35 commit ed96a4f

File tree

1 file changed

+145
-0
lines changed

1 file changed

+145
-0
lines changed

Programs/Chatbot.py

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# -*- coding: utf-8 -*-
2+
import nltk
3+
from nltk.chat.util import Chat, reflections
4+
5+
reflections = {
6+
"i am" : "you are",
7+
"i was" : "you were",
8+
"i" : "you",
9+
"i'm" : "you are",
10+
"i'd" : "you would",
11+
"i've" : "you have",
12+
"i'll" : "you will",
13+
"my" : "your",
14+
"you are" : "I am",
15+
"you were" : "I was",
16+
"you've" : "I have",
17+
"you'll" : "I will",
18+
"your" : "my",
19+
"yours" : "mine",
20+
"you" : "me",
21+
"me" : "you",
22+
23+
}
24+
pairs = [
25+
[
26+
r"my name is (.*)",
27+
["Hello %1, How are you today ?",]
28+
],
29+
[
30+
r"hi|hey|hello",
31+
["Hello", "Hey there",]
32+
],
33+
[
34+
r"what is your name ?|your name|name please",
35+
["I am Y2K. You can call me crazy individual!",]
36+
],
37+
[
38+
r"how are you ?|how you doing|what about you|how about you ?",
39+
["I'm doing good. How can I help you ?",]
40+
],
41+
[
42+
r"sorry (.*)",
43+
["Its alright","Its OK, never mind",]
44+
],
45+
[
46+
r"I am fine",
47+
["Great to hear that, How can I help you?",]
48+
],
49+
[
50+
r"(.*) continents",
51+
["Asia, Africa, North America, South America, Antarctica, Europe, and Australia ",]
52+
],
53+
[
54+
r"(.*) (english|hollywood) movie",
55+
["The Shawshank Redemption", " The Lord of the Rings: The Return of the King","Inception", "Interstellar", "Parasite", "Twilight", "Fast & Furious", "Lucky one","A walk to remember", "The Last Song", "The Notebook","The Fault in Our Stars", "Joker", "Me Before You", "All the boys have met before","Kissing booth", "Titanic",]
56+
],
57+
[
58+
r"i'm (.*) doing good",
59+
["Nice to hear that","How can I help you?:)",]
60+
],
61+
[
62+
r"(.*) age?|are you an (idiot|stupid)|what do you think you are",
63+
["I'm a computer program dude....Seriously you are asking me this?",]
64+
],
65+
[
66+
r"(.*) (online|free) courses",
67+
["Udemy","Udacity","Great Learning","Google Digital Garage","Swayam",]
68+
],
69+
[
70+
r"(.*) (news channel|news)",
71+
["BCC World News","Fox News","Cable News Network (CNN)","Sky News","MSNCB","Republic World","ZEE News","ABP News",]
72+
],
73+
[
74+
r"(.*) (horror|spooky) movie",
75+
["The Nun", "Annabelle", "The conjuring", "Sinister", "The cabin in the wood", "insidious", "IT","Ouija", "Train to Busan", "The Ring", "Hush", "Evil Dead", "Oculus",]
76+
],
77+
[
78+
r"(.*) (bollywood|hindi) movie",
79+
["War", "My name is Khan", "Happy new year", "Dilwale", "Uri", "Don", "Don 2", "Raees","Raazi", "Kalank", "Kalank", "Dangal", "LUDO", "Good Newz", "PK", "Jab Tak Hai Jaan","Cocktail", "Bahubali", "M.S.Dhoni", "Aashiqui 2","Dear Zindagi","Anand", "Mughal-E-Azam", "Mother India", "Don ", " Parinda", "Mr. India","Mera Naam Joker", "Amar, Akbar and Anthony", " Agneepath ", "Sahib Bibi Aur Ghulam","Sholay",]
80+
],
81+
[
82+
r"(.*) (webseries|series)",
83+
["You", "Lucifer", "Cursed", "Mismatched", "Money Heist", "Stranger Things", "Merlin","The Protector", "Sabrina", "Dark", "Friends", "The Big Bang Theory", "Little Things","Lock & Key", "Sherlock", "Sweet Tooth", "The Witcher", "Shadow and Bones","Never Have i ever", "Brooklyn Nine-Nine", "Ragnarok", "Originals", "Vampire Diaries","The Order", "The Boss Baby", "The Haunting of Hill House", "Pup Academy", "Mary Queen of Scots","Bitten", "Titans", "Warrior Nun","The Haunting of bly Manor",]
84+
],
85+
[
86+
r"(.*) k-drama",
87+
["descendants of the sun","busted", "her private life", "whats wrong with secretary kim","its okay to not be okay", "hospital playlist", "crash landing on you","weightlifting fairy kim bok joo", "my first first love", "beauty inside", "was it love",]
88+
],
89+
[
90+
r"(.*) (novel|book)",
91+
["Harry Potter", "Twilight", "Alchemist", "Angel And Demon", "Dead Beautiful", "Lost Symbol", "The Vinche Code", "Hunger Games",]
92+
],
93+
[
94+
r"(.*) created ?",
95+
["I am created using Python's NLTK library ","top secret",]
96+
],
97+
[
98+
r"(.*) band",
99+
["BTS", "The Beatles", "The rolling stones", "Maroon 5", "One Direction", "No Doubt","Black Pink", "EXO", "MonstaX", "Stray Kids","The chainsmokers",]
100+
],
101+
[
102+
r"(.*) actress",
103+
["Scarlett Johansson", "Jennifer Lawrence", "Emma Watson", " Margot Robbie","Angelina Jolie", "Kristen Stewart", "Rachel McAdams","Deepika Padukone", "Priyanka Chopra", "Alia Bhatt", "Kareena Kapoor","Nora Fatehi", "Jacqueline Fernandez", "Aishwarya Rai", "Sara Ali Khan", "Shraddha Kapoor","Anushka Sharma", "Disha Patani",]
104+
],
105+
[
106+
r"(.*) (game|sport)",
107+
["Cricket","Hockey", "Basketball", "Football", "Baseball","Badminton", "Tennis", "Swimming", "Archery","Skates", "Volleyball", "Table Tennis", "Golf",]
108+
],
109+
[
110+
r"(.*) (sports person|player)",
111+
["Lionel Messi","Sania Mirza", "Sachin Tendulkar", "Virat Kohli", "Kevin Durant","Hardik Pandya", "Rohit Sharma", "P. V. Sindhu", "Parupalli Kashyap","Sania Mirza", "Dhyan Chand", "Cristiano Ronaldo", "Robert Lewandowski","Chris Gayle", "Steve Smith", "David Warner", "Ricky Ponting","Stephen Curry", "LeBron James", "M.S.Dhoni", "Chris Paul",]
112+
],
113+
[
114+
r"(.*) actor",
115+
["Robert Downey, Jr.", "Chris Hemsworth", "Tom Holland", "Brad Pitt","Tom Hiddleston", "Tom Cruise", "Chris Evans", "Benedict Cumberbatch","Paul Rudd", "Jeremy Renner", "Ian Somerhalder ","Paul Wesley", "Aamir Khan", "Amitabh Bachchan","Anil Kapoor", "Ranveer Singh", "Ranbir Kapoor", "Salman Khan","Sanjay Dutt", "Shah Rukh Khan", "Tiger Shroff", "Varun Dhawan",]
116+
],
117+
[
118+
r"(.*) dialogue",
119+
["Mere paas maa hai.","Pushpa, I hate tears…","Kitne aadmi the!","Babumoshai, zindagi badi honi chahiye, lambi nahi.","Rishtey mein toh hum tumhare baap lagte hai, naam hai Shahenshaah!","Dosti ka ek usool hai madam – no sorry, no thank you.","Mogambo khush hua!","Hum jahan khade hote hain line yahi se shuru hoti hai.","Bade bade deshon mein aisi choti-choti baatein hoti rehti hai, Senorita.","Haar kar jeetne wale ko baazigar kehte hai.","Mere Karan Arjun aayenge.","Agar maa ka doodh piya hai toh samne aa!","Uska to na bad luck hi kharab hai.","Crime Master Gogo naam hai mera, aankhen nikal ke gotiyan khelta hun main.","Tareekh pe tareekh, tareekh pe tareekh, tareekh pe tareekh milti gayi My Lord, par insaaf nahi mila","Rahul, naam toh suna hi hoga.","Mein apni favourite hoon!","Picture abhi baaki hai mere dost!","How’s the josh?","Thappad se darr nahi lagta sahab, pyaar se lagta hai.","Filmein sirf teen cheezo ke wajah se chalti hai…entertainment, entertainment, entertainment…aur main entertainment hoon.","All izz well",]
120+
],
121+
[
122+
r"quit",
123+
["Bye take care. See you soon :) ","It was nice talking to you. See you soon :)",]
124+
],
125+
[
126+
r"(.*) joke",
127+
["Why did the tomato blush? Because it saw the salad dressing.","What do you call bears with no ears? B","What do dentists call X-rays? Tooth pics.","Did you hear about the first restaurant to open on the moon? It had great food, but no atmosphere.","What did one wall say to the other wall? I’ll meet you at the corner.","When does a joke become a “dad” joke? When the punchline is apparent.","What did the paper say to the pencil? Write on!","How did the bullet lose its job? It got fired.","Why should you never trust stairs? They are always up to something.","Sometimes I tuck my knees into my chest and lean forward.That’s just how I roll.","What do you call a cheese that’s not yours? Nacho cheese!","Did you hear about the cheese factory that exploded in France?There was nothing left but de Brie.",]
128+
],
129+
[
130+
r"even me",
131+
["That's great"]
132+
],
133+
[
134+
r"thank you",
135+
["Your welcome , would you like to know something else if no then please type in QUIT to exit",]
136+
],
137+
]
138+
def chat():
139+
print("Hi! I am Y2K..")
140+
chat = Chat(pairs, reflections)
141+
chat.converse()
142+
143+
#initiate the conversation
144+
if __name__ == "__main__":
145+
chat()

0 commit comments

Comments
 (0)