File size: 722 Bytes
add5eca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
from transformers import pipeline

# Load the sentiment analysis pipeline
sentiment_pipeline = pipeline("sentiment-analysis")

# Streamlit UI
st.title("Sentiment Analysis")
st.write("Enter text below to analyze sentiment:")

# Text input
user_input = st.text_area("Text input")

# Button to perform sentiment analysis
if st.button("Analyze Sentiment"):
    if user_input:
        # Perform sentiment analysis
        results = sentiment_pipeline(user_input)
        # Display the results
        sentiment = results[0]['label']
        score = results[0]['score']
        st.write(f"Sentiment: {sentiment} (Confidence: {score:.2f})")
    else:
        st.write("Please enter some text to analyze.")