|
import streamlit as st |
|
from transformers import pipeline |
|
|
|
|
|
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! |
|
""") |
|
|
|
|
|
user_input = st.text_area("Enter your text here:") |
|
|
|
|
|
if st.button("Analyze Sentiment"): |
|
if user_input.strip() == "": |
|
st.warning("Please enter some text to analyze.") |
|
else: |
|
|
|
sentiment_pipeline = pipeline("sentiment-analysis") |
|
result = sentiment_pipeline(user_input) |
|
|
|
|
|
sentiment = result[0]['label'] |
|
confidence = result[0]['score'] |
|
st.write(f"**Sentiment:** {sentiment}") |
|
st.write(f"**Confidence Score:** {confidence:.2f}") |
|
|