Spaces:
Runtime error
Runtime error
Commit
·
0976254
1
Parent(s):
020b686
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
dataset = pd.read_csv('a1_RestaurantReviews_HistoricDump.tsv', delimiter = '\t', quoting = 3)
|
| 3 |
+
import pickle
|
| 4 |
+
tokenizer=pickle.load(open("tokenizer.pkl","rb"))
|
| 5 |
+
from keras.utils import pad_sequences
|
| 6 |
+
model=pickle.load(open("model.pkl","rb"))
|
| 7 |
+
def calc(abc):
|
| 8 |
+
abc=[abc]
|
| 9 |
+
seq=tokenizer.texts_to_sequences(abc)
|
| 10 |
+
inp=pad_sequences(seq,padding='post',maxlen=51)
|
| 11 |
+
score=(model.predict(inp))[0][0]
|
| 12 |
+
if score>0.6:
|
| 13 |
+
return("positive")
|
| 14 |
+
elif score <0.4:
|
| 15 |
+
return("negative")
|
| 16 |
+
else:
|
| 17 |
+
return("neutral")
|
| 18 |
+
import gradio as gr
|
| 19 |
+
gr.Interface(fn=calc,inputs=gr.inputs.Textbox(placeholder="Input the feeedback to be reviewed"),outputs="textbox").launch();
|