dar-tau commited on
Commit
9758523
1 Parent(s): 051d927

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -51,9 +51,10 @@ def analyze_sentence(index, vis_type, vis_format):
51
  }]
52
  graph_output = displacy.render(ex, style="dep", jupyter=False, manual=True, options={"compact": True,
53
  "offset_x": 20,
54
- "distance": 100
55
  })
56
- graph_output = ("<style>.displacy_container svg{margin-top:-50px;}</style><div class='displacy_container' style='max-width:100%; zoom:80%; max-height:360px; overflow:auto'>"
 
57
  + graph_output +
58
  "</div>"
59
  )
@@ -63,6 +64,7 @@ def analyze_sentence(index, vis_type, vis_format):
63
  metrics.update({k: v for k, v in row.items() if k not in ['text', 'attention_maps', 'attention_maps_shape']})
64
  return fig_output, graph_output, metrics
65
 
 
66
  demo = gr.Blocks()
67
  with demo:
68
  with gr.Row():
@@ -79,7 +81,9 @@ with demo:
79
  output = gr.Plot(label="Plot", container=True)
80
  graph_output = gr.HTML()
81
  metrics = gr.Label("Metrics")
82
- btn.click(analyze_sentence, [sentence_dropdown, vis_dropdown, vis_format_checkbox], [output, graph_output, metrics])
 
 
83
 
84
 
85
  if __name__ == "__main__":
 
51
  }]
52
  graph_output = displacy.render(ex, style="dep", jupyter=False, manual=True, options={"compact": True,
53
  "offset_x": 20,
54
+ "distance": 130
55
  })
56
+ graph_output = ("<style>.displacy_container svg{margin-top:-50px;}</style>" +
57
+ "<div class='displacy_container' style='max-width:100%; zoom:80%; max-height:360px; overflow:auto'>"
58
  + graph_output +
59
  "</div>"
60
  )
 
64
  metrics.update({k: v for k, v in row.items() if k not in ['text', 'attention_maps', 'attention_maps_shape']})
65
  return fig_output, graph_output, metrics
66
 
67
+
68
  demo = gr.Blocks()
69
  with demo:
70
  with gr.Row():
 
81
  output = gr.Plot(label="Plot", container=True)
82
  graph_output = gr.HTML()
83
  metrics = gr.Label("Metrics")
84
+ btn.click(analyze_sentence,
85
+ [sentence_dropdown, vis_dropdown, vis_format_checkbox],
86
+ [output, graph_output, metrics])
87
 
88
 
89
  if __name__ == "__main__":