File size: 888 Bytes
27b2983 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import streamlit as st
from transformers import pipeline
# Title and Introduction
st.title("Sentiment Analysis App")
st.write("""
This app uses a Hugging Face model to analyze the sentiment of your text.
Type something below and click "Analyze Sentiment" to get started!
""")
# Text Input
user_input = st.text_area("Enter your text here:")
# Perform Sentiment Analysis
if st.button("Analyze Sentiment"):
if user_input.strip() == "":
st.warning("Please enter some text to analyze.")
else:
# Load the sentiment analysis pipeline
sentiment_pipeline = pipeline("sentiment-analysis")
result = sentiment_pipeline(user_input)
# Extract and display results
sentiment = result[0]['label']
confidence = result[0]['score']
st.write(f"**Sentiment:** {sentiment}")
st.write(f"**Confidence Score:** {confidence:.2f}")
|