Spaces:
Runtime error
Runtime error
Update app.py
#1
by
Suzana
- opened
app.py
CHANGED
@@ -1,9 +1,20 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
3 |
-
|
|
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import nltk
|
3 |
+
from nltk.sentiment.vader import SentimentIntensityAnalyzer
|
4 |
|
5 |
+
nltk.download("vader_lexicon")
|
6 |
+
sid = SentimentIntensityAnalyzer()
|
7 |
|
8 |
+
def sentiment_analysis(text):
|
9 |
+
scores = sid.polarity_scores(text)
|
10 |
+
del scores["compound"]
|
11 |
+
return scores
|
12 |
+
|
13 |
+
demo = gr.Interface(
|
14 |
+
fn=sentiment_analysis,
|
15 |
+
inputs=gr.Textbox(placeholder="Enter a positive or negative sentence here..."),
|
16 |
+
outputs="label",
|
17 |
+
interpretation="default",
|
18 |
+
examples=[["This is wonderful!"]])
|
19 |
+
|
20 |
+
demo.launch()
|