import streamlit as st from transformers import pipeline model_path = "citizenlab/twitter-xlm-roberta-base-sentiment-finetunned" st.set_page_config(page_title="Sentiment Analysis App") sentiment_classifier = pipeline("text-classification", model=model_path, tokenizer=model_path) st.title("Sentiment Analysis App") user_input = st.text_area("Enter a message:", height=150) if st.button("Analyze Sentiment 🚀", key="analyze_button", help="Click to analyze sentiment"): if user_input: # Perform sentiment analysis st.markdown("---") with st.spinner('Analyzing...'): results = sentiment_classifier(user_input) sentiment_label = results[0]["label"] sentiment_score = results[0]["score"] st.success("Analysis Complete! 🎉") st.write("") st.subheader("Sentiment Analysis Result") st.write(f"**Sentiment:** {sentiment_label}") st.write(f"**Confidence Score:** {sentiment_score:.2f}") # Colorful styled button if sentiment_label == "positive": button_color = "#33cc33" # green color for positive sentiment elif sentiment_label == "negative": button_color = "#ff3333" # red color for negative sentiment else: button_color = "#3399ff" # blue color for neutral sentiment st.markdown( f'' f'Share Analysis on Streamlit 🔗', unsafe_allow_html=True, )