File size: 624 Bytes
925da6e
 
 
3c7fc37
 
925da6e
3c7fc37
 
925da6e
3c7fc37
925da6e
3c7fc37
 
 
 
925da6e
3c7fc37
 
925da6e
3c7fc37
 
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

def main():
    sentiment_pipeline = pipeline("sentiment-analysis", model="distilbert/distilbert-base-uncased-finetuned-sst-2-english")

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

    user_input = st.text_input("")

    if user_input:
        result = sentiment_pipeline(user_input)
        sentiment = result[0]["label"]
        confidence = result[0]["score"]

        st.write(f"Sentiment: {sentiment.lower()}")
        st.write(f"Confidence: {confidence:.4f}")

if __name__ == "__main__":
    main()