File size: 807 Bytes
d86aeee
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import torch

# Use a pipeline as a high-level helper
from transformers import pipeline

text_classification = pipeline("text-classification", model="distilbert/distilbert-base-uncased-finetuned-sst-2-english")

def sentment_classifiction(text):
    output = text_classification(text)
    return output[0]['label']

# Streamlit UI
def run():
    st.title("Sentiment Analysis")
    st.write("Enter a comment below to analyze its sentiment.")

    text = st.text_area("Enter your text here:", "")
    if st.button("Analyze"):
        if text:
            with st.spinner("Analyzing the text..."):
                result = sentment_classifiction(text)

            st.success(f"**Sentiment:** {result}")
        else:
            st.warning("⚠️ Please enter some text for analysis.")