Rrrrrrrita/Deep_Learning_Project
0
1import streamlit as st2from transformers import pipeline3 4# Load the text summarization model pipeline5summarizer = pipeline("summarization", model="facebook/bart-large-cnn")6 7# Streamlit application title8st.title("Sentiment Analysis with text summarization for Singapore Airline")9 10# Text input for user to enter the text to summarize11text = st.text_area("Enter the text to analyze:", "")12 13# Perform text summarization when the user clicks the "Go!" button14if st.button("Go!"):15 # Perform text summarization on the input text16 results = summarizer(text)[0]['summary_text']17 st.write("Step 1: Text after summarization:")18 st.write(results)19 20 # Sentiment analysis as the second step21 classifier = pipeline("text-classification", model="Rrrrrrrita/Custom_Sentiment", return_all_scores=True)22 23 st.write('Step 2: Sentiment Analysis:')24 st.write("\t\t Classification for 3 emotions: positve, neutral, and negative")25 26 labels = classifier(text)[0]27 max_score = float('-inf')28 max_label = ''29 30 for label in labels:31 if label['score'] > max_score:32 max_score = label['score']33 max_label = label['label']34 35 36 st.write("\tLabel:", max_label)37 st.write("\tScore:", max_score)