-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinteractive.py
More file actions
24 lines (22 loc) · 748 Bytes
/
interactive.py
File metadata and controls
24 lines (22 loc) · 748 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
print ('Starting the classifier')
import classifier
print ('{}'.format("-"*80))
print ('Type \'quit\', \'q\', or \'\\q\' to exit the interactive shell')
while True:
try:
articleTitle = raw_input('\nArticle title: ').strip().decode('utf-8')
if articleTitle == 'quit' or articleTitle == 'q' or articleTitle == '\q':
print ('\nGracefully quitting...\n')
break
except:
break
classifiedProb = classifier.classifyArticle(articleTitle)
newsOrClickBait = ""
if classifiedProb['clickbait'] >= 0.5:
newsOrClickBait = 'CLICKBAIT'
else:
newsOrClickBait = 'NEWS'
print ("""({:.3f}% clickbait, {:.3f}% news) -> Article classified as {}""".format(
classifiedProb['clickbait'] * 100,
classifiedProb['news'] * 100,
newsOrClickBait))