wxrrrrrrr commited on
Commit
6b31dee
1 Parent(s): 9ffe71d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -0
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ # Summarization
5
+ def summarization(text):
6
+ text_model = pipeline("text-generation", model="ainize/bart-base-cnn")
7
+ summary = text_model(text, max_length=100, do_sample=False)[0]["generated_text"]
8
+ return summary
9
+
10
+ # Sentiment Classification
11
+ def sentiment_classification(summary):
12
+ sentiment_model = pipeline("text-classification", model="wxrrrrrrr/finetuned_sentiment_analysis")
13
+ result = sentiment_model(summary, max_length=100, do_sample=False)[0]['label']
14
+ return result
15
+
16
+ def main():
17
+ st.set_page_config(page_title="Your Text Analysis", page_icon="🦜")
18
+ st.header("Tell me your comments!")
19
+ text_input = st.text_input("Enter your text here:")
20
+
21
+ if text_input:
22
+ # Stage 1: Summarization
23
+ st.text('Processing text...')
24
+ summary = summarization(text_input)
25
+ # st.write(summary)
26
+
27
+ # Stage 2: Sentiment Classification
28
+ st.text('Analyzing sentiment...')
29
+ sentiment = sentiment_classification(summary)
30
+ st.write(sentiment)
31
+
32
+ # Display the classification result
33
+ st.write("Sentiment:", sentiment)
34
+
35
+ if __name__ == '__main__':
36
+ main()