aliabd commited on
Commit
0b6da2b
·
1 Parent(s): b590f90

Upload folder using huggingface_hub

Browse files
Files changed (5) hide show
  1. DESCRIPTION.md +1 -0
  2. README.md +8 -8
  3. requirements.txt +1 -0
  4. run.ipynb +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,12 @@
 
1
  ---
2
- title: Sentiment Analysis 3-x
3
- emoji: 🌍
4
- colorFrom: gray
5
- colorTo: yellow
6
  sdk: gradio
7
- sdk_version: 4.3.0
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_3-x
4
+ emoji: 🔥
5
+ colorFrom: indigo
6
+ colorTo: indigo
7
  sdk: gradio
8
+ sdk_version: 3.50.1
9
+ app_file: run.py
10
  pinned: false
11
+ hf_oauth: true
12
  ---
 
 
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ nltk
run.ipynb ADDED
@@ -0,0 +1 @@
 
 
1
+ {"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: sentiment_analysis\n", "### 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.\n", " "]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio nltk"]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import nltk\n", "from nltk.sentiment.vader import SentimentIntensityAnalyzer\n", "\n", "nltk.download(\"vader_lexicon\")\n", "sid = SentimentIntensityAnalyzer()\n", "\n", "def sentiment_analysis(text):\n", " scores = sid.polarity_scores(text)\n", " del scores[\"compound\"]\n", " return scores\n", "\n", "demo = gr.Interface(\n", " fn=sentiment_analysis, \n", " inputs=gr.Textbox(placeholder=\"Enter a positive or negative sentence here...\"), \n", " outputs=\"label\", \n", " interpretation=\"default\",\n", " examples=[[\"This is wonderful!\"]])\n", "\n", "demo.launch()"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
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()