Spaces:
Runtime error
Runtime error
Download app.py from AbdulQadoos/aaa: direct link, hf CLI and curl.
- Browser
- Download file 848 Bytes
-
https://huggingface.co/spaces/AbdulQadoos/aaa/resolve/main/app.py
- Command line
-
hf download hf://spaces/AbdulQadoos/aaa/app.py
-
curl -L -o app.py https://huggingface.co/spaces/AbdulQadoos/aaa/resolve/main/app.py
848 Bytes
| import gradio as gr | |
| import nltk | |
| from nltk.sentiment.vader import SentimentIntensityAnalyzer | |
| nltk.download('vader_lexicon') # Ensure VADER lexicon is downloaded | |
| def analyze_sentiment(text): | |
| sid = SentimentIntensityAnalyzer() | |
| sentiment_scores = sid.polarity_scores(text) | |
| if sentiment_scores['compound'] >= 0.05: | |
| sentiment = 'Positive' | |
| elif sentiment_scores['compound'] <= -0.05: | |
| sentiment = 'Negative' | |
| else: | |
| sentiment = 'Neutral' | |
| return sentiment, sentiment_scores | |
| iface = gr.Interface( | |
| fn=analyze_sentiment, | |
| inputs=[gr.Textbox(lines=5, placeholder="Enter your text here")], | |
| outputs=[gr.Textbox(label="Sentiment"), gr.JSON(label="Sentiment Scores")], | |
| title="Sentiment Analyzer by Qadoos Shaikh", | |
| description="Analyze the sentiment of your text using VADER", | |
| ) | |
| iface.launch() | |