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)