File size: 1,267 Bytes
add5eca
 
 
 
 
 
 
 
5e0244a
008b3a9
a9809e5
 
add5eca
 
 
 
 
84c8a10
add5eca
 
 
 
 
 
84c8a10
 
add5eca
5e0244a
7d9e4f3
 
 
 
 
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
27
28
29
30
31
32
33
34
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 analyse the sentiment.")
st.write("You can copy and paste a comment from social media for example.")
st.write("Usage idea: Companies can now quickly gather customers on mass who leave unhappy comments on social media to get in first before they leave a bad review.")
st.write("Making that crucial early contact to be proactive, rather than reactive, keeps your review ratings higher than your competitors.")

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

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


#Credit
st.write(" ")
st.write("Click [here](https://ai-solutions.ai) to visit AI Solutions.")