yesdeepakmittal commited on
Commit
1f4d723
·
1 Parent(s): f768609

app.py added

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pickle
3
+
4
+ from nltk.tokenize import word_tokenize
5
+ import nltk
6
+ nltk.download('all')
7
+
8
+ with open('LogisticRegression_classifier.pickle','rb') as fp:
9
+ LogisticRegression_classifier = pickle.load(fp)
10
+
11
+ with open('word_features5k.pickle','rb') as fp:
12
+ word_features = pickle.load(fp)
13
+
14
+
15
+ def find_features(news):
16
+ words = word_tokenize(news)
17
+ features = {}
18
+ for w in word_features:
19
+ features[w] = (w in words)
20
+ return features
21
+
22
+ def fn(news):
23
+ return LogisticRegression_classifier.classify(find_features(news))
24
+
25
+ iface = gr.Interface(
26
+ fn = fn,
27
+ inputs = 'text',
28
+ outputs = 'text'
29
+ )
30
+
31
+ url = iface.launch(share=True)
32
+ # return url[]