Spaces:
Runtime error
Runtime error
Commit
•
80a2499
1
Parent(s):
2143da4
update
Browse files
app.py
CHANGED
@@ -12,17 +12,24 @@ HF_TOKEN = os.environ["newsapi"]
|
|
12 |
newsapi = NewsApiClient(api_key=HF_TOKEN)
|
13 |
|
14 |
classifier = pipeline(model="cardiffnlp/twitter-roberta-base-sentiment")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
sentiment = ['Negative' if classifier(entry['content'])[0]['label'] == 'LABEL_0' else 'Neutral' if classifier(entry['content'])[0]['label'] == 'LABEL_1' else 'Positive' for entry in all_articles['articles']]
|
16 |
|
17 |
#Driver
|
18 |
def inference(newssource): #, date):
|
19 |
-
today = str(date.today())
|
20 |
-
all_articles = newsapi.get_everything(sources='the-times-of-india',
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
dictnews = { 'description' : [entry['description'] for entry in all_articles['articles']],
|
27 |
'content' : [entry['content'] for entry in all_articles['articles']],
|
28 |
'url' : [entry['url'] for entry in all_articles['articles']],
|
|
|
12 |
newsapi = NewsApiClient(api_key=HF_TOKEN)
|
13 |
|
14 |
classifier = pipeline(model="cardiffnlp/twitter-roberta-base-sentiment")
|
15 |
+
today = str(date.today())
|
16 |
+
all_articles = newsapi.get_everything(sources='the-times-of-india',
|
17 |
+
domains='timesofindia.indiatimes.com',
|
18 |
+
from_param=today,
|
19 |
+
to=today,
|
20 |
+
language='en',
|
21 |
+
sort_by='relevancy',)
|
22 |
sentiment = ['Negative' if classifier(entry['content'])[0]['label'] == 'LABEL_0' else 'Neutral' if classifier(entry['content'])[0]['label'] == 'LABEL_1' else 'Positive' for entry in all_articles['articles']]
|
23 |
|
24 |
#Driver
|
25 |
def inference(newssource): #, date):
|
26 |
+
#today = str(date.today())
|
27 |
+
#all_articles = newsapi.get_everything(sources='the-times-of-india',
|
28 |
+
# domains='timesofindia.indiatimes.com',
|
29 |
+
# from_param=today,
|
30 |
+
# to=today,
|
31 |
+
# language='en',
|
32 |
+
# sort_by='relevancy',)
|
33 |
dictnews = { 'description' : [entry['description'] for entry in all_articles['articles']],
|
34 |
'content' : [entry['content'] for entry in all_articles['articles']],
|
35 |
'url' : [entry['url'] for entry in all_articles['articles']],
|