Victoria Slocum commited on
Commit
96daa57
1 Parent(s): 32163e9
Files changed (1) hide show
  1. app.py +21 -6
app.py CHANGED
@@ -80,8 +80,8 @@ def span(text, span1, span2, label1, label2, model):
80
  idx2_1 = 0
81
  idx2_2 = 0
82
 
83
- span1 = span1.split(" ")
84
- span2 = span2.split(" ")
85
 
86
  for i in range(len(list(doc))):
87
  tok = list(doc)[i]
@@ -133,23 +133,26 @@ with demo:
133
  with gr.TabItem("Dependency"):
134
  col_punct = gr.Checkbox(label="Collapse Punctuation", value=True)
135
  col_phrase = gr.Checkbox(label="Collapse Phrases", value=True)
136
- compact = gr.Checkbox(label="Compact", value=True)
137
  depen_output = gr.HTML()
138
-
139
  with gr.TabItem("Entity"):
140
  entity_input = gr.CheckboxGroup(DEFAULT_ENTS, value=DEFAULT_ENTS)
141
  entity_output = gr.HTML()
 
142
  with gr.TabItem("Tokens"):
143
  with gr.Column():
144
  tok_input = gr.CheckboxGroup(
145
  DEFAULT_TOK_ATTR, value=DEFAULT_TOK_ATTR)
146
  tok_output = gr.Dataframe(
147
  headers=DEFAULT_TOK_ATTR, overflow_row_behaviour="paginate")
 
148
  with gr.TabItem("Similarity"):
149
  with gr.Row():
150
  sim_text1 = gr.Textbox(value="David Bowie", label="Chosen")
151
  sim_text2 = gr.Textbox(value="the US", label="Chosen")
152
  sim_output = gr.Textbox(value="0.09", label="Similarity Score")
 
153
  with gr.TabItem("Spans"):
154
  with gr.Column():
155
  with gr.Row():
@@ -160,8 +163,10 @@ with demo:
160
  span2 = gr.Textbox(label="Span 2")
161
  label2 = gr.Textbox(value="Label 2",
162
  label="Label for Span 2")
163
- with gr.Row():
164
- span_output = gr.HTML()
 
 
165
  text_button.click(get_text, inputs=[model_input], outputs=text_input)
166
  button.click(dependency, inputs=[
167
  text_input, col_punct, col_phrase, compact, model_input], outputs=depen_output)
@@ -173,5 +178,15 @@ with demo:
173
  sim_output, sim_text1, sim_text2])
174
  button.click(
175
  span, inputs=[text_input, span1, span2, label1, label2, model_input], outputs=span_output)
 
 
 
 
 
 
 
 
 
 
176
 
177
  demo.launch()
 
80
  idx2_1 = 0
81
  idx2_2 = 0
82
 
83
+ span1 = [split for split in span1.split(" ") if split]
84
+ span2 = [split for split in span2.split(" ") if split]
85
 
86
  for i in range(len(list(doc))):
87
  tok = list(doc)[i]
 
133
  with gr.TabItem("Dependency"):
134
  col_punct = gr.Checkbox(label="Collapse Punctuation", value=True)
135
  col_phrase = gr.Checkbox(label="Collapse Phrases", value=True)
136
+ compact = gr.Checkbox(label="Compact", value=False)
137
  depen_output = gr.HTML()
138
+ dep_button = gr.Button("Generate this tab")
139
  with gr.TabItem("Entity"):
140
  entity_input = gr.CheckboxGroup(DEFAULT_ENTS, value=DEFAULT_ENTS)
141
  entity_output = gr.HTML()
142
+ ent_button = gr.Button("Generate this tab")
143
  with gr.TabItem("Tokens"):
144
  with gr.Column():
145
  tok_input = gr.CheckboxGroup(
146
  DEFAULT_TOK_ATTR, value=DEFAULT_TOK_ATTR)
147
  tok_output = gr.Dataframe(
148
  headers=DEFAULT_TOK_ATTR, overflow_row_behaviour="paginate")
149
+ tok_button = gr.Button("Generate this tab")
150
  with gr.TabItem("Similarity"):
151
  with gr.Row():
152
  sim_text1 = gr.Textbox(value="David Bowie", label="Chosen")
153
  sim_text2 = gr.Textbox(value="the US", label="Chosen")
154
  sim_output = gr.Textbox(value="0.09", label="Similarity Score")
155
+ sim_button = gr.Button("Generate this tab")
156
  with gr.TabItem("Spans"):
157
  with gr.Column():
158
  with gr.Row():
 
163
  span2 = gr.Textbox(label="Span 2")
164
  label2 = gr.Textbox(value="Label 2",
165
  label="Label for Span 2")
166
+ span_output = gr.HTML()
167
+ gr.Markdown(value="\n\n\n\n")
168
+ gr.Markdown(value="\n\n\n\n")
169
+ span_button = gr.Button("Generate this tab")
170
  text_button.click(get_text, inputs=[model_input], outputs=text_input)
171
  button.click(dependency, inputs=[
172
  text_input, col_punct, col_phrase, compact, model_input], outputs=depen_output)
 
178
  sim_output, sim_text1, sim_text2])
179
  button.click(
180
  span, inputs=[text_input, span1, span2, label1, label2, model_input], outputs=span_output)
181
+ dep_button.click(dependency, inputs=[
182
+ text_input, col_punct, col_phrase, compact, model_input], outputs=depen_output)
183
+ ent_button.click(
184
+ entity, inputs=[text_input, entity_input, model_input], outputs=entity_output)
185
+ tok_button.click(
186
+ token, inputs=[text_input, tok_input, model_input], outputs=tok_output)
187
+ sim_button.click(vectors, inputs=[text_input, model_input], outputs=[
188
+ sim_output, sim_text1, sim_text2])
189
+ span_button.click(
190
+ span, inputs=[text_input, span1, span2, label1, label2, model_input], outputs=span_output)
191
 
192
  demo.launch()