Files changed (1) hide show
  1. app.py +17 -6
app.py CHANGED
@@ -1,9 +1,20 @@
1
  import gradio as gr
 
 
2
 
3
- examples = ["I love you", "I lost my wallet"]
 
4
 
5
- gr.Interface.load(
6
- "huggingface/j-hartmann/emotion-english-distilroberta-base",
7
- title="Basic emotion detection",
8
- examples = examples
9
- ).launch();
 
 
 
 
 
 
 
 
 
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()