lunadebruyne commited on
Commit
6d31d85
·
1 Parent(s): 7ddd7f1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -1
app.py CHANGED
@@ -10,9 +10,22 @@ def what_happened(text, file_object, option_list):
10
  if len(option_list) > 0:
11
  output = output + "\nYou can only select options when uploading a dataset."
12
  return output
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
 
15
- iface = gr.Interface(
16
  fn=what_happened,
17
  inputs=[
18
  gr.Textbox(
@@ -26,4 +39,26 @@ iface = gr.Interface(
26
  label = "Select options")
27
  ],
28
  outputs="text")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  iface.launch()
 
10
  if len(option_list) > 0:
11
  output = output + "\nYou can only select options when uploading a dataset."
12
  return output
13
+
14
+ def what_happened1(text):
15
+ output = "Normally, this demo should analyse the emotions in this text:\n" + text
16
+ return output
17
+
18
+ def what_happened2(file_object, option_list):
19
+ if file_object:
20
+ output = "You uploaded a file."
21
+ if len(option_list) > 0:
22
+ output = output + "\nYou selected these options:\n- " + "\n- ".join(option_list)
23
+ else:
24
+ output = "You should upload a file."
25
+ return output
26
 
27
 
28
+ iface0 = gr.Interface(
29
  fn=what_happened,
30
  inputs=[
31
  gr.Textbox(
 
39
  label = "Select options")
40
  ],
41
  outputs="text")
42
+
43
+ iface1 = gr.Interface(
44
+ fn=what_happened1,
45
+ gr.Textbox(
46
+ label= "Enter a sentence",
47
+ lines=1,
48
+ value="Your name")
49
+ outputs="text")
50
+
51
+ iface2 = gr.Interface(
52
+ fn=what_happened2,
53
+ inputs=[
54
+ gr.File(
55
+ label="Upload a dataset"),
56
+ gr.CheckboxGroup(
57
+ ["emotion frequencies", "emotion distribution over time", "peaks", "topics"],
58
+ label = "Select options")
59
+ ],
60
+ outputs="text")
61
+
62
+ iface = gr.TabbedInterface([iface1, iface2], ["Sentence", "Dataset"])
63
+
64
  iface.launch()