aliabd HF staff commited on
Commit
d1ecd20
1 Parent(s): 1f94fd8

Upload with huggingface_hub

Browse files
Files changed (5) hide show
  1. DESCRIPTION.md +1 -0
  2. README.md +6 -7
  3. __pycache__/run.cpython-36.pyc +0 -0
  4. requirements.txt +1 -0
  5. run.py +20 -0
DESCRIPTION.md ADDED
@@ -0,0 +1 @@
 
 
1
+ This sentiment analaysis demo takes in input text and returns its classification for either positive, negative or neutral using Gradio's Label output. It also uses the default interpretation method so users can click the Interpret button after a submission and see which words had the biggest effect on the output.
README.md CHANGED
@@ -1,12 +1,11 @@
 
1
  ---
2
- title: Sentiment Analysis Main
3
- emoji: 👁
4
- colorFrom: pink
5
- colorTo: blue
6
  sdk: gradio
7
  sdk_version: 3.6
8
- app_file: app.py
9
  pinned: false
10
  ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+
2
  ---
3
+ title: sentiment_analysis_main
4
+ emoji: 🔥
5
+ colorFrom: indigo
6
+ colorTo: indigo
7
  sdk: gradio
8
  sdk_version: 3.6
9
+ app_file: run.py
10
  pinned: false
11
  ---
 
 
__pycache__/run.cpython-36.pyc ADDED
Binary file (633 Bytes). View file
 
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ nltkhttps://gradio-main-build.s3.amazonaws.com/c3bec6153737855510542e8154391f328ac72606/gradio-3.6-py3-none-any.whl
run.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()