WillWEI0103 commited on
Commit
419e174
·
verified ·
1 Parent(s): 871a959

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ def sentiment(summary):
5
+ pipe = pipeline("text-classification", model="WillWEI0103/CustomModel_finance_sentiment_analytics")
6
+ label = pipe(summary)[0]['label']
7
+ return label
8
+
9
+
10
+ def main():
11
+ dicts={"bullish":'Positive📈',"bearish":'Negative📉','neutral':"Neutral😐"}
12
+ #st.set_page_config(page_title="Your Finance news", page_icon="📰")
13
+ st.header("Summarize Your Finance News and Analyze Sentiment")
14
+ text=st.text_input('Input your Finance news(Max lenth<=3000): ',max_chars=3000)
15
+ if isinstance(text,str):
16
+ st.text('Your Finance news📰": ')
17
+ st.write(str(text))
18
+
19
+ #Stage 1: Text Summarization
20
+ st.text('Processing Finance News Summarization...')
21
+ text_summarize=pipeline("summarization", model="nickmuchi/fb-bart-large-finetuned-trade-the-event-finance-summarizer")
22
+ summary=text_summarize(text)[0]['summary_text']
23
+ st.write(summary)
24
+
25
+ #Stage 2: Sentiment Analytics
26
+ st.text('Processing Sentiment Analytics...')
27
+ label = sentiment(summary)
28
+ label=dicts[label]
29
+ st.text('The sentiment of finance news is: ')
30
+ st.write(label)
31
+
32
+ if __name__ == "__main__":
33
+ main()