WillWEI0103 commited on
Commit
7c2ff9d
·
verified ·
1 Parent(s): d231fce

Create app.py

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