File size: 1,251 Bytes
132c5cf
 
 
 
 
 
 
 
 
 
0d24a94
132c5cf
 
 
 
 
0d24a94
 
132c5cf
 
 
0d24a94
 
 
132c5cf
 
 
 
 
 
 
 
 
 
0d24a94
 
 
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
35
36
37
import streamlit as st
from transformers import pipeline

# Load the text summarization model pipeline
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")

# Streamlit application title
st.title("Sentiment Analysis with text summarization for Singapore Airline")

# Text input for user to enter the text to summarize
text = st.text_area("Enter the text to analyze:", "")

# Perform text summarization when the user clicks the "Go!" button
if st.button("Go!"):
    # Perform text summarization on the input text
    results = summarizer(text)[0]['summary_text']
    st.write("Step 1: Text after summarization:")
    st.write(results)

    # Sentiment analysis as the second step
    classifier = pipeline("text-classification", model="Rrrrrrrita/Custom_Sentiment", return_all_scores=True)

    st.write('Step 2: Sentiment Analysis:')
    st.write("\t\t Classification for 3 emotions: positve, neutral, and negative")

    labels = classifier(text)[0]
    max_score = float('-inf')
    max_label = ''
    
    for label in labels:
        if label['score'] > max_score:
            max_score = label['score']
            max_label = label['label']
            

    st.write("\tLabel:", max_label)
    st.write("\tScore:", max_score)