Spaces:
Runtime error
Runtime error
Commit
·
ab2c9b6
1
Parent(s):
6153bc6
Update app.py
Browse files
app.py
CHANGED
@@ -10,20 +10,25 @@ dataset_api = project.get_dataset_api()
|
|
10 |
|
11 |
dataset = load_dataset("torileatherman/sentiment_analysis_batch_predictions", split='train')
|
12 |
predictions_df = pd.DataFrame(dataset)
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
[predictions_df_url2]]
|
19 |
|
20 |
def article_selection(sentiment):
|
21 |
if sentiment == "Positive":
|
22 |
-
|
|
|
|
|
23 |
elif sentiment == "Negative":
|
24 |
-
|
|
|
|
|
25 |
else:
|
26 |
-
|
|
|
|
|
27 |
|
28 |
def thanks(url, sentiment):
|
29 |
thanks_text = "Thank you for making our model better!"
|
@@ -54,7 +59,7 @@ manual_label_demo = gr.Interface(
|
|
54 |
inputs=[gr.Textbox(label = "Paste in URL of news article here."),
|
55 |
gr.Dropdown(["Positive","Negative","Neutral"], label="Select the sentiment of the news article.")],
|
56 |
outputs = gr.Textbox(label="Output"),
|
57 |
-
description =
|
58 |
)
|
59 |
|
60 |
|
|
|
10 |
|
11 |
dataset = load_dataset("torileatherman/sentiment_analysis_batch_predictions", split='train')
|
12 |
predictions_df = pd.DataFrame(dataset)
|
13 |
+
grouped_predictions = predictions_df.groupby(predictions_df.Sentiment)
|
14 |
+
positive_preds = grouped_predictions.get_group(2)
|
15 |
+
neutral_preds = grouped_predictions.get_group(1)
|
16 |
+
negative_preds = grouped_predictions.get_group(0)
|
17 |
+
|
|
|
18 |
|
19 |
def article_selection(sentiment):
|
20 |
if sentiment == "Positive":
|
21 |
+
predictions = positive_preds
|
22 |
+
predictions_urls = predictions['Url'][0:3]
|
23 |
+
return predictions_urls
|
24 |
elif sentiment == "Negative":
|
25 |
+
predictions = negative_preds
|
26 |
+
predictions_urls = predictions['Url'][0:3]
|
27 |
+
return predictions_urls
|
28 |
else:
|
29 |
+
predictions = neutral_preds
|
30 |
+
predictions_urls = predictions['Url'][0:3]
|
31 |
+
return predictions_urls
|
32 |
|
33 |
def thanks(url, sentiment):
|
34 |
thanks_text = "Thank you for making our model better!"
|
|
|
59 |
inputs=[gr.Textbox(label = "Paste in URL of news article here."),
|
60 |
gr.Dropdown(["Positive","Negative","Neutral"], label="Select the sentiment of the news article.")],
|
61 |
outputs = gr.Textbox(label="Output"),
|
62 |
+
description = description2
|
63 |
)
|
64 |
|
65 |
|