Kovila
commited on
Commit
·
08a3338
1
Parent(s):
004a155
sentiment analysis
Browse files
app.py
CHANGED
@@ -78,31 +78,36 @@ def get_news_sentiment(news):
|
|
78 |
return postive, neutral, negative
|
79 |
|
80 |
# APP
|
|
|
|
|
81 |
st.title('Financial News Headlines Summarization and Sentiment')
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
st.
|
88 |
-
|
89 |
-
st.
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
st.
|
|
|
|
|
|
|
|
78 |
return postive, neutral, negative
|
79 |
|
80 |
# APP
|
81 |
+
col1, col2 = st.columns(2)
|
82 |
+
|
83 |
st.title('Financial News Headlines Summarization and Sentiment')
|
84 |
+
|
85 |
+
with col1:
|
86 |
+
st.write('Enter the stock ticker and period for which you want financial news headlines.')
|
87 |
+
stock_ticker = st.text_input('Stock Ticker:', 'AAPL')
|
88 |
+
start_date = st.date_input('Start Date:', datetime.datetime.today()-datetime.timedelta(days=20))
|
89 |
+
end_date = st.date_input('End Date:', datetime.datetime.today())
|
90 |
+
news = financial_news(stock_ticker, start_date, end_date)
|
91 |
+
st.write(news)
|
92 |
+
|
93 |
+
with col2:
|
94 |
+
st.header('Financial News Sentiment')
|
95 |
+
with st.spinner('finbert model getting sentiment...'):
|
96 |
+
positive, neutral, negative = get_news_sentiment(news)
|
97 |
+
|
98 |
+
# white: #D0D3D4
|
99 |
+
# red: #E74C3C
|
100 |
+
# green: #2ECC71
|
101 |
+
sentiment_df = pd.DataFrame(
|
102 |
+
{
|
103 |
+
'sentiment_labels':['positive', 'neutral', 'negative'],
|
104 |
+
'sentiment':[positive, neutral, negative],
|
105 |
+
'color':['#2ECC71', '#D0D3D4', '#E74C3C']
|
106 |
+
}
|
107 |
+
)
|
108 |
+
st.bar_chart(sentiment_df, x='sentiment_labels', y='sentiment', color='color', horizontal=True)
|
109 |
+
|
110 |
+
st.header('Financial News Summary')
|
111 |
+
with st.spinner('facebook bart model is summarizing the news...'):
|
112 |
+
news_summary = get_news_summary(news)
|
113 |
+
st.write(news_summary)
|