Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,10 @@
|
|
1 |
import streamlit as st
|
2 |
-
from nltk.sentiment.vader import SentimentIntensityAnalyzer
|
3 |
import nltk
|
|
|
4 |
|
5 |
# Ensure the VADER lexicon is downloaded
|
6 |
nltk.download('vader_lexicon')
|
7 |
|
8 |
-
|
9 |
class SentimentAnalyzer:
|
10 |
def __init__(self):
|
11 |
self.analyzer = SentimentIntensityAnalyzer()
|
@@ -13,11 +12,10 @@ class SentimentAnalyzer:
|
|
13 |
def analyze_sentiment(self, sentence):
|
14 |
return self.analyzer.polarity_scores(sentence)
|
15 |
|
16 |
-
|
17 |
def fool():
|
18 |
analyzer = SentimentAnalyzer()
|
19 |
|
20 |
-
st.title("Sentiment Analysis App")
|
21 |
st.write("Enter a sentence to analyze its sentiment:")
|
22 |
|
23 |
# Input text box for user input
|
@@ -27,7 +25,7 @@ def fool():
|
|
27 |
if sentence:
|
28 |
# Perform sentiment analysis
|
29 |
result = analyzer.analyze_sentiment(sentence)
|
30 |
-
|
31 |
# Interpret sentiment label
|
32 |
compound_score = result['compound']
|
33 |
if compound_score >= 0.05:
|
@@ -36,10 +34,9 @@ def fool():
|
|
36 |
sentiment_type = 'Negative'
|
37 |
else:
|
38 |
sentiment_type = 'Neutral'
|
39 |
-
|
40 |
# Display sentiment analysis result
|
41 |
st.write(f"Sentiment: {sentiment_type}, Score: {compound_score:.4f}")
|
42 |
|
43 |
-
|
44 |
# Call fool function directly if the script is executed
|
45 |
fool()
|
|
|
1 |
import streamlit as st
|
|
|
2 |
import nltk
|
3 |
+
from nltk.sentiment.vader import SentimentIntensityAnalyzer
|
4 |
|
5 |
# Ensure the VADER lexicon is downloaded
|
6 |
nltk.download('vader_lexicon')
|
7 |
|
|
|
8 |
class SentimentAnalyzer:
|
9 |
def __init__(self):
|
10 |
self.analyzer = SentimentIntensityAnalyzer()
|
|
|
12 |
def analyze_sentiment(self, sentence):
|
13 |
return self.analyzer.polarity_scores(sentence)
|
14 |
|
|
|
15 |
def fool():
|
16 |
analyzer = SentimentAnalyzer()
|
17 |
|
18 |
+
st.title("Sentiment Analysis App using VADER")
|
19 |
st.write("Enter a sentence to analyze its sentiment:")
|
20 |
|
21 |
# Input text box for user input
|
|
|
25 |
if sentence:
|
26 |
# Perform sentiment analysis
|
27 |
result = analyzer.analyze_sentiment(sentence)
|
28 |
+
|
29 |
# Interpret sentiment label
|
30 |
compound_score = result['compound']
|
31 |
if compound_score >= 0.05:
|
|
|
34 |
sentiment_type = 'Negative'
|
35 |
else:
|
36 |
sentiment_type = 'Neutral'
|
37 |
+
|
38 |
# Display sentiment analysis result
|
39 |
st.write(f"Sentiment: {sentiment_type}, Score: {compound_score:.4f}")
|
40 |
|
|
|
41 |
# Call fool function directly if the script is executed
|
42 |
fool()
|