s2049 commited on
Commit
64b7228
·
verified ·
1 Parent(s): bbf863f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -5
app.py CHANGED
@@ -17,11 +17,20 @@ def analyze_sentiment(text):
17
  with gr.Blocks() as demo:
18
  gr.Markdown("## Sentiment Analysis Demo")
19
 
20
- gr.Markdown("##### Example Inputs:")
21
- gr.Markdown("- \"I love this product! It's amazing!\"")
22
- gr.Markdown("- \"This was the worst experience I've ever had.\"")
23
- gr.Markdown("- \"The movie was okay, not great but not bad either.\"")
24
- gr.Markdown("- \"Absolutely fantastic! I would recommend it to everyone.\"")
 
 
 
 
 
 
 
 
 
25
 
26
  with gr.Row():
27
  input_text = gr.Textbox(
@@ -39,6 +48,12 @@ with gr.Blocks() as demo:
39
  lines=1
40
  )
41
 
 
 
 
 
 
 
42
  analyze_button.click(
43
  fn=analyze_sentiment,
44
  inputs=input_text,
 
17
  with gr.Blocks() as demo:
18
  gr.Markdown("## Sentiment Analysis Demo")
19
 
20
+ with gr.Row():
21
+ examples_dropdown = gr.Dropdown(
22
+ label="Click to load example texts",
23
+ choices=[
24
+ "I love this product! It's amazing!",
25
+ "This was the worst experience I've ever had.",
26
+ "The movie was okay, not great but not bad either.",
27
+ "Absolutely fantastic! I would recommend it to everyone."
28
+ ],
29
+ interactive=True
30
+ )
31
+
32
+ def load_example(selected_example):
33
+ return selected_example
34
 
35
  with gr.Row():
36
  input_text = gr.Textbox(
 
48
  lines=1
49
  )
50
 
51
+ examples_dropdown.change(
52
+ fn=load_example,
53
+ inputs=examples_dropdown,
54
+ outputs=input_text
55
+ )
56
+
57
  analyze_button.click(
58
  fn=analyze_sentiment,
59
  inputs=input_text,