Spaces:
Sleeping
Sleeping
File size: 1,096 Bytes
dc24cad | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | import streamlit as st
# Simple keyword lists
positive_words = ["good", "great", "excellent", "happy", "love", "fantastic", "amazing"]
negative_words = ["bad", "terrible", "awful", "sad", "hate", "horrible", "poor"]
# App title
st.set_page_config(page_title="Sentiment Analysis", page_icon="π¬")
st.title("π¬ Simple Sentiment Analysis App")
st.write("This is a basic sentiment analysis app using simple keyword matching.")
# User input
text = st.text_area("Enter text to analyze:")
# Function for basic sentiment check
def analyze_sentiment(text):
text = text.lower()
pos_count = sum(word in text for word in positive_words)
neg_count = sum(word in text for word in negative_words)
if pos_count > neg_count:
return "Positive π"
elif neg_count > pos_count:
return "Negative π"
else:
return "Neutral π"
# Analyze button
if st.button("Analyze Sentiment"):
if text.strip() == "":
st.warning("Please enter some text.")
else:
sentiment = analyze_sentiment(text)
st.success(f"Sentiment: **{sentiment}**")
|