Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,20 +6,23 @@ summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
|
| 6 |
|
| 7 |
# Streamlit application title
|
| 8 |
st.title("Sentiment Analysis with text summarization for Singapore Airline")
|
| 9 |
-
st.write("Summarization first, then sentiment analysis")
|
| 10 |
|
| 11 |
# Text input for user to enter the text to summarize
|
| 12 |
-
text = st.text_area("Enter the text to analyze", "")
|
| 13 |
|
| 14 |
# Perform text summarization when the user clicks the "Go!" button
|
| 15 |
if st.button("Go!"):
|
| 16 |
# Perform text summarization on the input text
|
| 17 |
results = summarizer(text)[0]['summary_text']
|
| 18 |
-
st.write("Step 1: Text after summarization:"
|
|
|
|
| 19 |
|
| 20 |
# Sentiment analysis as the second step
|
| 21 |
classifier = pipeline("text-classification", model="Rrrrrrrita/Custom_Sentiment", return_all_scores=True)
|
| 22 |
-
|
|
|
|
|
|
|
| 23 |
|
| 24 |
labels = classifier(text)[0]
|
| 25 |
max_score = float('-inf')
|
|
@@ -30,6 +33,6 @@ if st.button("Go!"):
|
|
| 30 |
max_score = label['score']
|
| 31 |
max_label = label['label']
|
| 32 |
|
| 33 |
-
|
| 34 |
-
st.write("
|
| 35 |
-
st.write("
|
|
|
|
| 6 |
|
| 7 |
# Streamlit application title
|
| 8 |
st.title("Sentiment Analysis with text summarization for Singapore Airline")
|
| 9 |
+
st.write("Summarization first, then sentiment analysis.")
|
| 10 |
|
| 11 |
# Text input for user to enter the text to summarize
|
| 12 |
+
text = st.text_area("Enter the text to analyze:", "")
|
| 13 |
|
| 14 |
# Perform text summarization when the user clicks the "Go!" button
|
| 15 |
if st.button("Go!"):
|
| 16 |
# Perform text summarization on the input text
|
| 17 |
results = summarizer(text)[0]['summary_text']
|
| 18 |
+
st.write("Step 1: Text after summarization:")
|
| 19 |
+
st.write(results)
|
| 20 |
|
| 21 |
# Sentiment analysis as the second step
|
| 22 |
classifier = pipeline("text-classification", model="Rrrrrrrita/Custom_Sentiment", return_all_scores=True)
|
| 23 |
+
|
| 24 |
+
st.write('Step 2: Sentiment Analysis:')
|
| 25 |
+
st.write("\t\t Classification for 3 emotions: positve, neutral, and negative")
|
| 26 |
|
| 27 |
labels = classifier(text)[0]
|
| 28 |
max_score = float('-inf')
|
|
|
|
| 33 |
max_score = label['score']
|
| 34 |
max_label = label['label']
|
| 35 |
|
| 36 |
+
|
| 37 |
+
st.write("\tLabel:", max_label)
|
| 38 |
+
st.write("\tScore:", max_score)
|