import streamlit as st # Page config st.set_page_config( page_title="Sentiment Analysis", page_icon="đŦ", layout="centered" ) # Custom styles st.markdown(""" """, unsafe_allow_html=True) # App title and intro st.title("đŦ Sentiment Analysis App") st.markdown("Predict sentiment using simple Python logic â no ML, just rule-based đ") # Input section st.subheader("đ Enter your text") user_input = st.text_area("", placeholder="Type or paste your sentence here...") # Keywords positive_words = ["good", "great", "happy", "excellent", "amazing", "love", "awesome", "fantastic", "positive", "nice"] negative_words = ["bad", "sad", "terrible", "horrible", "hate", "awful", "worst", "angry", "negative", "poor"] # Sentiment analysis function 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", "positive" elif neg_count > pos_count: return "âšī¸ Negative", "negative" else: return "đ Neutral", "neutral" # Button & result if st.button("đ Analyze Sentiment"): if user_input.strip(): sentiment, sentiment_class = analyze_sentiment(user_input) st.markdown(f'