WillWEI0103 commited on
Commit
6e7d6b6
·
verified ·
1 Parent(s): 545ea81

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
+ def text_summarize(text):
5
+ pipe = pipeline("summarization", model="nickmuchi/fb-bart-large-finetuned-trade-the-event-finance-summarizer")
6
+ summary = pipe(text)[0]['summary_text']
7
+ print(summary)
8
+ return summary
9
+
10
+ def sentiment(summary):
11
+ pipe = pipeline("text-classification", model="WillWEI0103/CustomModel_finance_sentiment_analytics")
12
+ label = pipe(summary)[0]['label']
13
+ return label
14
+
15
+
16
+ def main():
17
+ st.set_page_config(page_title="Your Finance news", page_icon="📰")
18
+ st.header("Summarize Your Finance News and Analyze Sentiment")
19
+ text=st.text_input('Input your Finance news: (Max lenth<=3000)',max_chars=3000)
20
+ st.text('Your Finance news: ')
21
+ st.write(str(text))
22
+
23
+ #Stage 1: Text Summarization
24
+ summary = text_summarize(text)
25
+ summary = summary[0]['summary_text']
26
+ st.text('Processing Finance News Summarization...')
27
+ st.write(summary)
28
+
29
+ #Stage 2: Sentiment Analytics
30
+ st.text('Processing Sentiment Analytics...')
31
+ label = sentiment(summary)
32
+ st.text('The sentiment of finance news is: ')
33
+ st.write(label)
34
+
35
+ if __name__ == "__main__":
36
+ main()