andreslu commited on
Commit
5074ad0
Β·
1 Parent(s): 038f7f8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -6
app.py CHANGED
@@ -4,6 +4,13 @@ from inductor import BartInductor
4
  inductor = BartInductor()
5
 
6
  def bart(text):
 
 
 
 
 
 
 
7
  #results = inductor.generate(text)
8
  results=[('<mask> is the capital and largest city of <mask>.', 0.0075895977795922415), ('<mask> is the largest city in <mask>.', 0.005302619071099926), ('<mask> is the most populous state in <mask>.', 0.0036559513972044544), ('<mask> is the capital of <mask>.', 0.0028800265140167813), ('<mask> is a state in <mask>.', 0.002295685033583364), ('<mask> is a capital of <mask>.', 0.001348920570936385), ('<mask> has one of the highest rates of poverty in <mask>.', 0.0012284877234430835), ('<mask> is a major commercial and financial centre of <mask>.', 0.001225910195650215), ('<mask> was then a part of <mask>.', 0.0007620440367924856), ('<mask>, the capital of the country, is the largest city in <mask>.', 0.0006940517028590776)]
9
  results = [(result[0], float(result[1]) * 100) for result in results]
@@ -13,15 +20,15 @@ def bart(text):
13
  bivar = gr.Interface(fn=bart,
14
  inputs=gr.inputs.Textbox(default='<mask> is the capital of <mask>.'),
15
  outputs=gr.Label(),
16
- title="BART Inductor",
17
- examples=[['<mask> is the capital of <mask>.']],
18
  description="Enter a text prompt to generate text using BART.")
19
 
20
- trivar = gr.Interface(fn=bart,
21
- inputs=gr.inputs.Textbox(default='<mask> is the capital of <mask>.'),
22
  outputs=gr.Label(),
23
- title="BART Inductor",
24
- examples=[['<mask> is the capital of <mask>.']],
25
  description="Enter a text prompt to generate text using BART.")
26
 
27
  demo = gr.TabbedInterface([bivar, trivar], ["εŒε˜ι‡", "δΈ‰ε˜ι‡"])
 
4
  inductor = BartInductor()
5
 
6
  def bart(text):
7
+ results = inductor.generate(text)
8
+ #results=[('<mask> is the capital and largest city of <mask>.', 0.0075895977795922415), ('<mask> is the largest city in <mask>.', 0.005302619071099926), ('<mask> is the most populous state in <mask>.', 0.0036559513972044544), ('<mask> is the capital of <mask>.', 0.0028800265140167813), ('<mask> is a state in <mask>.', 0.002295685033583364), ('<mask> is a capital of <mask>.', 0.001348920570936385), ('<mask> has one of the highest rates of poverty in <mask>.', 0.0012284877234430835), ('<mask> is a major commercial and financial centre of <mask>.', 0.001225910195650215), ('<mask> was then a part of <mask>.', 0.0007620440367924856), ('<mask>, the capital of the country, is the largest city in <mask>.', 0.0006940517028590776)]
9
+ results = [(result[0], float(result[1]) * 100) for result in results]
10
+ results_dict = {result[0]: float(result[1]) for result in results}
11
+ return results_dict
12
+
13
+ def bart2(text):
14
  #results = inductor.generate(text)
15
  results=[('<mask> is the capital and largest city of <mask>.', 0.0075895977795922415), ('<mask> is the largest city in <mask>.', 0.005302619071099926), ('<mask> is the most populous state in <mask>.', 0.0036559513972044544), ('<mask> is the capital of <mask>.', 0.0028800265140167813), ('<mask> is a state in <mask>.', 0.002295685033583364), ('<mask> is a capital of <mask>.', 0.001348920570936385), ('<mask> has one of the highest rates of poverty in <mask>.', 0.0012284877234430835), ('<mask> is a major commercial and financial centre of <mask>.', 0.001225910195650215), ('<mask> was then a part of <mask>.', 0.0007620440367924856), ('<mask>, the capital of the country, is the largest city in <mask>.', 0.0006940517028590776)]
16
  results = [(result[0], float(result[1]) * 100) for result in results]
 
20
  bivar = gr.Interface(fn=bart,
21
  inputs=gr.inputs.Textbox(default='<mask> is the capital of <mask>.'),
22
  outputs=gr.Label(),
23
+ title="BART Inductor εŒε˜ι‡",
24
+ examples=[['<mask> is the capital of <mask>.'],['<mask> is founder of <mask>.']],
25
  description="Enter a text prompt to generate text using BART.")
26
 
27
+ trivar = gr.Interface(fn=bart2,
28
+ inputs=gr.inputs.Textbox(default='<mask> is the parent of <mask>, who is the sibling of <mask>.'),
29
  outputs=gr.Label(),
30
+ title="BART Inductor δΈ‰ε˜ι‡",
31
+ examples=[['<mask> is the parent of <mask>, who is the sibling of <mask>.']],
32
  description="Enter a text prompt to generate text using BART.")
33
 
34
  demo = gr.TabbedInterface([bivar, trivar], ["εŒε˜ι‡", "δΈ‰ε˜ι‡"])