Spaces:
Runtime error
Runtime error
Commit
·
6b08e4f
1
Parent(s):
20764a9
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,22 +12,22 @@ with open('tokenizer.pickle', 'rb') as file:
|
|
| 12 |
def decide(text):
|
| 13 |
tokenized_text = tokenizer.texts_to_sequences([text])
|
| 14 |
padded_tokens = pad_sequences(tokenized_text, maxlen= 200)
|
| 15 |
-
result = model.predict(padded_tokens
|
| 16 |
-
if result
|
| 17 |
-
return f"Positive review with {result
|
| 18 |
-
elif result
|
| 19 |
-
return f"Negative review with {result
|
| 20 |
else:
|
| 21 |
return "Neutral Review"
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
-
example_sentence_1 = "I hate the movie, they made no effort in making the movie. Waste of time!"
|
| 26 |
-
example_sentence_2 = "Awesome movie! Loved the way in which the hero acted."
|
| 27 |
-
examples = [[example_sentence_1], [example_sentence_2]]
|
| 28 |
|
| 29 |
-
description = "Write out a movie review to know the underlying sentiment."
|
| 30 |
|
| 31 |
-
gr.Interface(decide, inputs= gr.inputs.Textbox( lines=1, placeholder=None, default="", label=None), outputs='text', examples=examples,
|
| 32 |
-
|
| 33 |
-
|
|
|
|
| 12 |
def decide(text):
|
| 13 |
tokenized_text = tokenizer.texts_to_sequences([text])
|
| 14 |
padded_tokens = pad_sequences(tokenized_text, maxlen= 200)
|
| 15 |
+
result = model.predict(padded_tokens)[0][0]
|
| 16 |
+
if result > 0.6 :
|
| 17 |
+
return f"Positive review with {result : .0%} prediction score"
|
| 18 |
+
elif result < 0.4:
|
| 19 |
+
return f"Negative review with {result : .0%} prediction score"
|
| 20 |
else:
|
| 21 |
return "Neutral Review"
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
+
#example_sentence_1 = "I hate the movie, they made no effort in making the movie. Waste of time!"
|
| 26 |
+
#example_sentence_2 = "Awesome movie! Loved the way in which the hero acted."
|
| 27 |
+
#examples = [[example_sentence_1], [example_sentence_2]]
|
| 28 |
|
| 29 |
+
#description = "Write out a movie review to know the underlying sentiment."
|
| 30 |
|
| 31 |
+
#gr.Interface(decide, inputs= gr.inputs.Textbox( lines=1, placeholder=None, default="", label=None), outputs='text', examples=examples,
|
| 32 |
+
# title="Sentiment analysis of movie reviews",description=description, allow_flagging="auto",
|
| 33 |
+
# flagging_dir='flagging records').launch( enable_queue = True, inline=False, share = True)
|