File size: 579 Bytes
418e309
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import streamlit as st
from transformers import pipeline

@st.cache(allow_output_mutation=True)
def load_pipeline():
    return pipeline("sentiment-analysis")

classifier = load_pipeline()

st.title("Sentiment Analysis App")
st.write("Enter a sentence to analyze its sentiment.")

user_input = st.text_input("Sentence:", "")

if st.button("Analyze"):
    if user_input:
        result = classifier(user_input)
        st.write("Sentiment:", result[0]['label'])
        st.write("Confidence:", result[0]['score'])
    else:
        st.write("Please enter a sentence to analyze.")