Spaces:
Runtime error
Runtime error
Commit
·
b59e911
1
Parent(s):
8c1a379
Update app.py
Browse files
app.py
CHANGED
@@ -29,7 +29,6 @@ def article_selection(sentiment):
|
|
29 |
predictions_df_url1 = predictions['Url'].iloc[1]
|
30 |
predictions_df_url2 = predictions['Url'].iloc[2]
|
31 |
return predictions_df_url0, predictions_df_url1, predictions_df_url2
|
32 |
-
|
33 |
else:
|
34 |
predictions = negative_preds
|
35 |
predictions_df_url0 = predictions['Url'].iloc[0]
|
@@ -37,9 +36,16 @@ def article_selection(sentiment):
|
|
37 |
predictions_df_url2 = predictions['Url'].iloc[2]
|
38 |
return predictions_df_url0, predictions_df_url1, predictions_df_url2
|
39 |
|
40 |
-
def
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
description1 = '''
|
45 |
This application recommends news articles depending on the sentiment of the headline.
|
@@ -47,9 +53,8 @@ description1 = '''
|
|
47 |
'''
|
48 |
|
49 |
description2 = '''
|
50 |
-
This application
|
51 |
-
|
52 |
-
The more data we have, the better news articles we can recommend to you!
|
53 |
'''
|
54 |
|
55 |
suggestion_demo = gr.Interface(
|
@@ -60,7 +65,12 @@ suggestion_demo = gr.Interface(
|
|
60 |
description = description1
|
61 |
)
|
62 |
|
63 |
-
manual_label_demo = gr.
|
|
|
|
|
|
|
|
|
|
|
64 |
fn=thanks,
|
65 |
title="Manually Label a News Article",
|
66 |
inputs=[gr.Textbox(label = "Paste in URL of news article here."),
|
|
|
29 |
predictions_df_url1 = predictions['Url'].iloc[1]
|
30 |
predictions_df_url2 = predictions['Url'].iloc[2]
|
31 |
return predictions_df_url0, predictions_df_url1, predictions_df_url2
|
|
|
32 |
else:
|
33 |
predictions = negative_preds
|
34 |
predictions_df_url0 = predictions['Url'].iloc[0]
|
|
|
36 |
predictions_df_url2 = predictions['Url'].iloc[2]
|
37 |
return predictions_df_url0, predictions_df_url1, predictions_df_url2
|
38 |
|
39 |
+
def manual_label(sentiment):
|
40 |
+
# Encoding sentiment data
|
41 |
+
predictions_df['Sentiment'] = predictions_df['Sentiment'].map({0: 'Negative', 1: 'Neutral', 2: 'Positive'})
|
42 |
+
|
43 |
+
# Selecting random row from batch data
|
44 |
+
random_sample = predictions_df.sample()
|
45 |
+
random_headline = random_sample['Headline_string'].iloc[0]
|
46 |
+
random_prediction = random_sample['Sentiment'].iloc[0]
|
47 |
+
return random_headline, random_prediction
|
48 |
+
|
49 |
|
50 |
description1 = '''
|
51 |
This application recommends news articles depending on the sentiment of the headline.
|
|
|
53 |
'''
|
54 |
|
55 |
description2 = '''
|
56 |
+
This application will show you a random news headline and our predicted sentiment.
|
57 |
+
In order to improve our model, mark the real sentiment of this headline!
|
|
|
58 |
'''
|
59 |
|
60 |
suggestion_demo = gr.Interface(
|
|
|
65 |
description = description1
|
66 |
)
|
67 |
|
68 |
+
manual_label_demo = gr.Blocks() as demo:
|
69 |
+
output = [gr.Textbox(label="News Headline"),gr.Textbox(label="Our Predicted Sentiment")],
|
70 |
+
generate_btn = gr.Button('Show me a headline!')
|
71 |
+
generate_btn.click(fn=manual_label, outputs=output)
|
72 |
+
|
73 |
+
manual_label_demo1 = gr.Interface(
|
74 |
fn=thanks,
|
75 |
title="Manually Label a News Article",
|
76 |
inputs=[gr.Textbox(label = "Paste in URL of news article here."),
|