torileatherman commited on
Commit
ab2c9b6
·
1 Parent(s): 6153bc6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -10
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
- predictions_df_url0 = predictions_df['Url'].iloc[0]
14
- predictions_df_url1 = predictions_df['Url'].iloc[1]
15
- predictions_df_url2 = predictions_df['Url'].iloc[2]
16
- predictions_df_urls = [[predictions_df_url0],
17
- [predictions_df_url1],
18
- [predictions_df_url2]]
19
 
20
  def article_selection(sentiment):
21
  if sentiment == "Positive":
22
- return predictions_df_urls #f"""The sentence you requested is Positive!"""
 
 
23
  elif sentiment == "Negative":
24
- return f"""The sentence you requested is Negative!"""
 
 
25
  else:
26
- return f"""The sentence you requested is Neutral!"""
 
 
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 = description1
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