Spaces:
Running
Running
Upload with huggingface_hub
Browse files- DESCRIPTION.md +1 -0
- README.md +6 -7
- __pycache__/run.cpython-36.pyc +0 -0
- requirements.txt +1 -0
- 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:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.6
|
8 |
-
app_file:
|
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()
|