Spaces:
Runtime error
Runtime error
Commit
·
6f92159
1
Parent(s):
55f82ec
Update app.py
Browse files
app.py
CHANGED
@@ -19,23 +19,26 @@ dataset = load_dataset("torileatherman/sentiment_analysis_training", split='trai
|
|
19 |
training_df = pd.DataFrame(dataset)
|
20 |
random_sample = {}
|
21 |
|
|
|
|
|
|
|
22 |
def article_selection(sentiment):
|
23 |
if sentiment == "Positive":
|
24 |
predictions = positive_preds
|
25 |
-
top3 = predictions[0:
|
26 |
top3_result = top3[['Headline_string','Url']]
|
27 |
top3_result.rename(columns = {'Headline_string':'Headlines', 'Url':'URL'})
|
28 |
return top3_result
|
29 |
|
30 |
elif sentiment == "Negative":
|
31 |
predictions = negative_preds
|
32 |
-
top3 = predictions[0:
|
33 |
top3_result = top3[['Headline_string','Url']]
|
34 |
top3_result.rename(columns = {'Headline_string':'Headlines', 'Url':'URL'})
|
35 |
return top3_result
|
36 |
else:
|
37 |
predictions = neutral_preds
|
38 |
-
top3 = predictions[0:
|
39 |
top3_result = top3[['Headline_string','Url']]
|
40 |
top3_result.rename(columns = {'Headline_string':'Headlines', 'Url':'URL'})
|
41 |
return top3_result
|
|
|
19 |
training_df = pd.DataFrame(dataset)
|
20 |
random_sample = {}
|
21 |
|
22 |
+
# Number of articles shown
|
23 |
+
n = 5
|
24 |
+
|
25 |
def article_selection(sentiment):
|
26 |
if sentiment == "Positive":
|
27 |
predictions = positive_preds
|
28 |
+
top3 = predictions[0:n]
|
29 |
top3_result = top3[['Headline_string','Url']]
|
30 |
top3_result.rename(columns = {'Headline_string':'Headlines', 'Url':'URL'})
|
31 |
return top3_result
|
32 |
|
33 |
elif sentiment == "Negative":
|
34 |
predictions = negative_preds
|
35 |
+
top3 = predictions[0:n]
|
36 |
top3_result = top3[['Headline_string','Url']]
|
37 |
top3_result.rename(columns = {'Headline_string':'Headlines', 'Url':'URL'})
|
38 |
return top3_result
|
39 |
else:
|
40 |
predictions = neutral_preds
|
41 |
+
top3 = predictions[0:n]
|
42 |
top3_result = top3[['Headline_string','Url']]
|
43 |
top3_result.rename(columns = {'Headline_string':'Headlines', 'Url':'URL'})
|
44 |
return top3_result
|