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}**")