import streamlit as st from textblob import TextBlob def main(): # Page configuration st.set_page_config( page_title="Basic Sentiment Analysis", page_icon="🔄", layout="centered" ) # Custom CSS for styling st.markdown(""" """, unsafe_allow_html=True) # Header st.title("Basic Sentiment Analysis") st.markdown("Enter text below to analyze its sentiment (without using pre-trained models).") # Text input user_input = st.text_area("Enter your text:", height=100, placeholder="Type something like 'I love this!' or 'This is terrible.'") if st.button("Analyze Sentiment"): if user_input: # Analyze sentiment using TextBlob analysis = TextBlob(user_input) polarity = analysis.sentiment.polarity # Determine sentiment category if polarity > 0.2: sentiment = "Positive 😊" emotion_class = "positive" elif polarity < -0.2: sentiment = "Negative 😞" emotion_class = "negative" else: sentiment = "Neutral 😐" emotion_class = "neutral" # Display results st.markdown(f"