Tomás F commited on
Commit
a143bbf
1 Parent(s): 2bd1ee1

Fix date published on

Browse files
Files changed (1) hide show
  1. app.py +13 -5
app.py CHANGED
@@ -1,6 +1,10 @@
 
 
1
  import feedparser
2
  import streamlit as st
3
- from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
 
 
4
 
5
 
6
  @st.cache(allow_output_mutation=True, show_spinner=False)
@@ -56,9 +60,13 @@ target_sentiments = st.sidebar.multiselect(
56
  default=sentiment_distribution.keys())
57
 
58
  with st.spinner('📰 Loading articles...'):
59
- target_articles = sorted(load_news(
60
- rss_feeds.get(target_source)
61
- ), key=lambda a: a.published_parsed)
 
 
 
 
62
 
63
  with st.spinner('⚙️ Analysing articles...'):
64
  classified_articles = classify_articles(target_articles, pipe)
@@ -85,7 +93,7 @@ for article, sentiment in filter_with_sentiment(classified_articles, target_sent
85
  st.markdown(
86
  f'''
87
  #### {article.title}
88
- Published on {article.published_parsed}
89
  **Sentiment:** {sentiment.get('label').capitalize()}
90
  '''
91
  )
 
1
+ from time import strftime
2
+
3
  import feedparser
4
  import streamlit as st
5
+
6
+ from transformers import AutoTokenizer, pipeline, \
7
+ AutoModelForSequenceClassification
8
 
9
 
10
  @st.cache(allow_output_mutation=True, show_spinner=False)
 
60
  default=sentiment_distribution.keys())
61
 
62
  with st.spinner('📰 Loading articles...'):
63
+ target_articles = sorted(
64
+ load_news(
65
+ rss_feeds.get(target_source)
66
+ ),
67
+ key=lambda article: article.published_parsed,
68
+ reverse=True
69
+ )
70
 
71
  with st.spinner('⚙️ Analysing articles...'):
72
  classified_articles = classify_articles(target_articles, pipe)
 
93
  st.markdown(
94
  f'''
95
  #### {article.title}
96
+ Published on {strftime(article.published_parsed, '%H:%M %d/%m/%Y')}
97
  **Sentiment:** {sentiment.get('label').capitalize()}
98
  '''
99
  )