Skip to content

Commit 361fbc0

Browse files
authored
Update chatbot.py
1 parent f2d31f5 commit 361fbc0

File tree

1 file changed

+0
-37
lines changed

1 file changed

+0
-37
lines changed

chatbot.py

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,15 @@
33

44
# # Meet Robo: your friend
55

6-
# In[3]:
7-
8-
96
import nltk
107

11-
12-
# In[ ]:
13-
14-
158
# nltk.download() # for downloading packages
169

17-
18-
# In[1]:
19-
20-
2110
import numpy as np
2211
import random
2312
import string # to process standard python strings
2413

2514

26-
# In[4]:
27-
28-
2915
f=open('corpus.txt','r',errors = 'ignore')
3016
raw=f.read()
3117
raw=raw.lower()# converts to lowercase
@@ -35,21 +21,12 @@
3521
word_tokens = nltk.word_tokenize(raw)# converts to list of words
3622

3723

38-
# In[5]:
39-
40-
4124
sent_tokens[:2]
4225

4326

44-
# In[6]:
45-
46-
4727
word_tokens[:5]
4828

4929

50-
# In[7]:
51-
52-
5330
lemmer = nltk.stem.WordNetLemmatizer()
5431
def LemTokens(tokens):
5532
return [lemmer.lemmatize(token) for token in tokens]
@@ -58,15 +35,10 @@ def LemNormalize(text):
5835
return LemTokens(nltk.word_tokenize(text.lower().translate(remove_punct_dict)))
5936

6037

61-
# In[8]:
62-
63-
6438
GREETING_INPUTS = ("hello", "hi", "greetings", "sup", "what's up","hey",)
6539
GREETING_RESPONSES = ["hi", "hey", "*nods*", "hi there", "hello", "I am glad! You are talking to me"]
6640

6741

68-
# In[9]:
69-
7042

7143
# Checking for greetings
7244
def greeting(sentence):
@@ -76,16 +48,10 @@ def greeting(sentence):
7648
return random.choice(GREETING_RESPONSES)
7749

7850

79-
# In[10]:
80-
81-
8251
from sklearn.feature_extraction.text import TfidfVectorizer
8352
from sklearn.metrics.pairwise import cosine_similarity
8453

8554

86-
# In[11]:
87-
88-
8955
# Generating response
9056
def response(user_response):
9157
robo_response=''
@@ -104,9 +70,6 @@ def response(user_response):
10470
return robo_response
10571

10672

107-
# In[12]:
108-
109-
11073
flag=True
11174
print("ROBO: My name is Robo. I will answer your queries about Chatbots. If you want to exit, type Bye!")
11275

0 commit comments

Comments
 (0)