Kovila commited on
Commit
08a3338
·
1 Parent(s): 004a155

sentiment analysis

Browse files
Files changed (1) hide show
  1. app.py +32 -27
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
- st.write('Enter the stock ticker and period for which you want financial news headlines.')
83
- stock_ticker = st.text_input('Stock Ticker:', 'AAPL')
84
- start_date = st.date_input('Start Date:', datetime.datetime.today()-datetime.timedelta(days=20))
85
- end_date = st.date_input('End Date:', datetime.datetime.today())
86
- news = financial_news(stock_ticker, start_date, end_date)
87
- st.write(news)
88
-
89
- st.header('Financial News Sentiment')
90
- with st.spinner('finbert model getting sentiment...'):
91
- positive, neutral, negative = get_news_sentiment(news)
92
-
93
- # white: #D0D3D4
94
- # red: #E74C3C
95
- # green: #2ECC71
96
- sentiment_df = pd.DataFrame(
97
- {
98
- 'sentiment_labels':['positive', 'neutral', 'negative'],
99
- 'sentiment':[positive, neutral, negative],
100
- 'color':['#2ECC71', '#D0D3D4', '#E74C3C']
101
- }
102
- )
103
- st.bar_chart(sentiment_df, x='sentiment_labels', y='sentiment', color='color', horizontal=True)
104
-
105
- st.header('Financial News Summary')
106
- with st.spinner('facebook bart model is summarizing the news...'):
107
- news_summary = get_news_summary(news)
108
- st.write(news_summary)
 
 
 
 
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)