fitsblb's picture
Upload 2 files
e9aa866 verified
import streamlit as st
from transformers import pipeline
# Load the sentiment pipeline
sentiment_pipeline = pipeline("sentiment-analysis", model="fitsblb/YelpReviewsAnalyzer")
def map_sentiment_label(label):
return {
"LABEL_0": "❌ Negative",
"LABEL_1": "⚖️ Neutral",
"LABEL_2": "✅ Positive"
}.get(label, "🤷 Unknown")
st.set_page_config(page_title="Yelp Sentiment Analyzer", layout="centered")
st.title("🍽️ Yelp Sentiment Analyzer")
st.markdown("Enter a restaurant review and see the model's sentiment prediction:")
example = "The food was amazing but the wait was long."
review = st.text_area("Review", example)
if st.button("Analyze Sentiment"):
if review.strip() == "":
st.warning("Please enter a review.")
else:
with st.spinner("Analyzing..."):
result = sentiment_pipeline(review)[0]
label = result["label"]
confidence = round(result["score"], 3)
st.success(f"**Sentiment:** {map_sentiment_label(label)}\n\n**Confidence:** {confidence}")