-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
00aed62
commit 408a445
Showing
6 changed files
with
187 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Anything,class | ||
Hii,0 | ||
Hey,0 | ||
Hello,0 | ||
Hii,0 | ||
Yo,0 | ||
what is your name,1 | ||
who are you,1 | ||
hey myra,1 | ||
wats ur name,1 | ||
What's your name,1 | ||
what you like to eat,2 | ||
wat is ur favourite thing to eat,2 | ||
what you eat most,2 | ||
What's your favourite food,2 | ||
wats ur favourite food,2 | ||
what r u doing,3 | ||
wats up,3 | ||
what's up,3 | ||
wassup,3 | ||
where you like to visit,4 | ||
wat is ur favourite place to visit,4 | ||
what you visit most,4 | ||
What's your favourite place,4 | ||
wats ur favourite site to visit,4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from sklearn.feature_extraction.text import CountVectorizer | ||
from sklearn.naive_bayes import MultinomialNB | ||
from sklearn.externals import joblib | ||
count_vect = joblib.load("count_vect.pkl") | ||
clf_count = joblib.load("clf_count.pkl") | ||
|
||
from res_map import responses | ||
res = responses() | ||
|
||
print 'input your query' | ||
ask = raw_input() | ||
test_example = [ask] | ||
test_example_count = count_vect.transform(test_example) | ||
probs = clf_count.predict_proba(test_example_count)[0] | ||
out = clf_count.predict(test_example_count)[0] | ||
outn = int(out) | ||
print res[outn] | ||
|
||
print out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
res = [] | ||
#0 | ||
temp = ("Hii \nWassup \nHow may I help you? \n") | ||
res.append(temp) | ||
#1 | ||
temp = ("I am Myra") | ||
res.append(temp) | ||
#2 | ||
temp = ("Current") | ||
res.append(temp) | ||
#3 | ||
temp = ("Chatting with you :) ") | ||
res.append(temp) | ||
#4 | ||
temp = ("IIT Roorkee ") | ||
res.append(temp) | ||
|
||
def responses(): | ||
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
|
||
# coding: utf-8 | ||
|
||
# In[1]: | ||
|
||
|
||
import csv | ||
from res_map import responses | ||
res = responses() | ||
|
||
data_path = "C:\Users\GAURABH\Desktop\Chat Bot\data5.csv" | ||
data = [] | ||
target=[] | ||
i = 0 | ||
with open(data_path) as datafile: | ||
filereader = csv.reader(datafile,delimiter =',',quotechar='|') | ||
initial = 0 | ||
for row in filereader: | ||
if initial == 0: | ||
initial = 1 | ||
continue | ||
else: | ||
data.append(row[0]) | ||
target.append(row[1]) | ||
data = data[1:] | ||
target = target[1:] | ||
|
||
|
||
# In[2]: | ||
|
||
|
||
from sklearn.feature_extraction.text import CountVectorizer | ||
from sklearn.naive_bayes import MultinomialNB | ||
from sklearn.externals import joblib | ||
#import joblib | ||
|
||
count_vect = CountVectorizer() | ||
train_counts = count_vect.fit_transform(data) | ||
|
||
clf_count = MultinomialNB(alpha=1,fit_prior='false').fit(train_counts,target) | ||
''' | ||
count_path = "trained_model/naive_count/count_vect.pkl" | ||
clf_path = "trained_model/naive_count/clf_count.pkl" | ||
joblib.dump(count_vect,count_path) | ||
joblib.dump(clf_count,clf_path) | ||
''' | ||
joblib.dump(count_vect,'count_vect.pkl') | ||
joblib.dump(clf_count,'clf_count.pkl') | ||
|
||
# In[3]: | ||
|
||
|
||
#test_example = ["will kissing cause hiv"] | ||
#test_example_count = count_vect.transform(test_example) | ||
''' | ||
def respond(self): | ||
print 'input your query' | ||
ask = raw_input() | ||
vec = self.vector(ask) | ||
no = self.clf.predict(vec)[0] | ||
no = int(no) | ||
return self.res[no] | ||
print 'input your query' | ||
ask = raw_input() | ||
test_example = [ask] | ||
test_example_count = count_vect.transform(test_example) | ||
probs = clf_count.predict_proba(test_example_count)[0] | ||
out = clf_count.predict(test_example_count)[0] | ||
outn = int(out) | ||
print res[outn] | ||
# In[4]: | ||
print out | ||
# In[1]: | ||
from sklearn.feature_extraction.text import CountVectorizer | ||
from sklearn.naive_bayes import MultinomialNB | ||
import joblib | ||
count_vect = joblib.load("trained_model/naive_count/count_vect.pkl") | ||
clf_count = joblib.load("trained_model/naive_count/clf_count.pkl") | ||
''' | ||
''' | ||
count_vect = joblib.load("count_vect.pkl") | ||
clf_count = joblib.load("clf_count.pkl") | ||
''' | ||
# In[6]: | ||
|
||
''' | ||
test_example = ["will kissing cause hiv"] | ||
test_example_count = count_vect.transform(test_example) | ||
probs = clf_count.predict_proba(test_example_count)[0] | ||
out = clf_count.predict(test_example_count) | ||
# In[9]: | ||
out = out[0] | ||
''' | ||
# In[11]: | ||
|
||
''' | ||
from map_englishu import mapping | ||
# In[12]: | ||
mapping[out] | ||
''' | ||
# In[ ]: | ||
|
||
|
||
|
||
|