-
Notifications
You must be signed in to change notification settings - Fork 0
/
tst2.py
45 lines (30 loc) · 849 Bytes
/
tst2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from textblob.classifiers import NaiveBayesClassifier
from textblob import TextBlob
train = [
('2','4'),
('4','8'),('6','12'),('8','16'),('10','20')
]
while 0<1:
cl = NaiveBayesClassifier(train)
inp=raw_input("enter a sentence \n")
ans=cl.classify(inp)
print(ans)
fb=raw_input("corect or not y/n \n")
if(fb=="y"):
train.append([inp,ans])
elif(ans=='pos'):
train.append([inp,'neg'])
elif(ans=='neg'):
train.append([inp,'pos'])
from textblob.classifiers import NaiveBayesClassifier
from textblob import TextBlob
train = [
('2','4'),
('4','8'),('6','12'),('8','16'),('10','20')
]
cl = NaiveBayesClassifier(train)
# Classify some text
inp=raw_input("enter a sentence \n")
print(cl.classify(inp))
# Show 5 most informative features
cl.show_informative_features(5)