Victoria Slocum commited on
Commit
551011b
1 Parent(s): fd44dc1

small refactor

Browse files
Files changed (1) hide show
  1. app.py +57 -61
app.py CHANGED
@@ -154,28 +154,26 @@ with demo:
154
  gr.Image("pipeline.svg")
155
  with gr.Box():
156
  with gr.Column():
 
157
  with gr.Row():
158
  with gr.Column():
159
- gr.Markdown(" ## Choose a language model and text")
160
- with gr.Row():
161
- with gr.Column():
162
- model_input = gr.Dropdown(
163
- choices=models, value=DEFAULT_MODEL, interactive=True, label="Pretrained Pipelines")
164
- with gr.Column():
165
- gr.Markdown("")
166
- with gr.Column():
167
- gr.Markdown("")
168
- with gr.Column():
169
- gr.Markdown("")
170
-
171
- with gr.Row():
172
- with gr.Column():
173
- text_input = gr.Textbox(
174
- value=DEFAULT_TEXT, interactive=True, label="Input Text")
175
- with gr.Column():
176
- gr.Markdown("")
177
-
178
- button = gr.Button("Generate", variant="primary")
179
  with gr.Tabs():
180
  with gr.TabItem(""):
181
  with gr.Column():
@@ -196,10 +194,9 @@ with demo:
196
  with gr.Column():
197
  text = gr.Textbox(
198
  label="Text Color", value="black")
199
- with gr.Row():
200
- with gr.Column():
201
- depen_output = gr.HTML(value=dependency(
202
- DEFAULT_TEXT, True, True, False, DEFAULT_COLOR, "black", DEFAULT_MODEL))
203
  dep_button = gr.Button("Generate Dependency Parser")
204
  gr.Markdown(" ")
205
  with gr.Box():
@@ -219,15 +216,14 @@ with demo:
219
  "## [Token Properties](https://spacy.io/usage/linguistic-features)")
220
  gr.Markdown(
221
  "When you put in raw text to spaCy, it returns a Doc object with different linguistic features")
222
- with gr.Column():
223
- with gr.Row():
224
- with gr.Column():
225
- tok_input = gr.CheckboxGroup(
226
- DEFAULT_TOK_ATTR, value=DEFAULT_TOK_ATTR)
227
- with gr.Column():
228
- gr.Markdown("")
229
- tok_output = gr.Dataframe(headers=DEFAULT_TOK_ATTR, value=default_token(
230
- DEFAULT_TEXT, DEFAULT_TOK_ATTR, DEFAULT_MODEL), overflow_row_behaviour="paginate")
231
  tok_button = gr.Button("Generate Token Properties")
232
  with gr.Box():
233
  with gr.Column():
@@ -255,34 +251,34 @@ with demo:
255
  "## [Spans](https://spacy.io/usage/visualizers#span)")
256
  gr.Markdown(
257
  "The span visualizer highlights overlapping spans in a text.")
258
- with gr.Column():
259
- with gr.Row():
260
- with gr.Column():
261
- span1 = gr.Textbox(
262
- label="Span 1", value="U.K. startup", placeholder="Input a part of the sentence")
263
- with gr.Column():
264
- label1 = gr.Textbox(value="ORG",
265
- label="Label for Span 1")
266
- with gr.Column():
267
- gr.Markdown("")
268
- with gr.Column():
269
- gr.Markdown("")
270
- with gr.Row():
271
- with gr.Column():
272
- span2 = gr.Textbox(
273
- label="Span 2", value="U.K.", placeholder="Input another part of the sentence")
274
- with gr.Column():
275
- label2 = gr.Textbox(value="GPE",
276
- label="Label for Span 2")
277
- with gr.Column():
278
- gr.Markdown("")
279
- with gr.Column():
280
- gr.Markdown("")
281
- span_output = gr.HTML(value=span(
282
- DEFAULT_TEXT, "U.K. startup", "U.K.", "ORG", "GPE", DEFAULT_MODEL))
283
- gr.Markdown(value="\n\n\n\n")
284
- gr.Markdown(value="\n\n\n\n")
285
- span_button = gr.Button("Generate spans")
286
 
287
  model_input.change(get_text, inputs=[model_input], outputs=text_input)
288
  button.click(dependency, inputs=[
 
154
  gr.Image("pipeline.svg")
155
  with gr.Box():
156
  with gr.Column():
157
+ gr.Markdown(" ## Choose a language model and text")
158
  with gr.Row():
159
  with gr.Column():
160
+ model_input = gr.Dropdown(
161
+ choices=models, value=DEFAULT_MODEL, interactive=True, label="Pretrained Pipelines")
162
+ with gr.Column():
163
+ gr.Markdown("")
164
+ with gr.Column():
165
+ gr.Markdown("")
166
+ with gr.Column():
167
+ gr.Markdown("")
168
+
169
+ with gr.Row():
170
+ with gr.Column():
171
+ text_input = gr.Textbox(
172
+ value=DEFAULT_TEXT, interactive=True, label="Input Text")
173
+ with gr.Column():
174
+ gr.Markdown("")
175
+
176
+ button = gr.Button("Generate", variant="primary")
 
 
 
177
  with gr.Tabs():
178
  with gr.TabItem(""):
179
  with gr.Column():
 
194
  with gr.Column():
195
  text = gr.Textbox(
196
  label="Text Color", value="black")
197
+
198
+ depen_output = gr.HTML(value=dependency(
199
+ DEFAULT_TEXT, True, True, False, DEFAULT_COLOR, "black", DEFAULT_MODEL))
 
200
  dep_button = gr.Button("Generate Dependency Parser")
201
  gr.Markdown(" ")
202
  with gr.Box():
 
216
  "## [Token Properties](https://spacy.io/usage/linguistic-features)")
217
  gr.Markdown(
218
  "When you put in raw text to spaCy, it returns a Doc object with different linguistic features")
219
+ with gr.Row():
220
+ with gr.Column():
221
+ tok_input = gr.CheckboxGroup(
222
+ DEFAULT_TOK_ATTR, value=DEFAULT_TOK_ATTR)
223
+ with gr.Column():
224
+ gr.Markdown("")
225
+ tok_output = gr.Dataframe(headers=DEFAULT_TOK_ATTR, value=default_token(
226
+ DEFAULT_TEXT, DEFAULT_TOK_ATTR, DEFAULT_MODEL), overflow_row_behaviour="paginate")
 
227
  tok_button = gr.Button("Generate Token Properties")
228
  with gr.Box():
229
  with gr.Column():
 
251
  "## [Spans](https://spacy.io/usage/visualizers#span)")
252
  gr.Markdown(
253
  "The span visualizer highlights overlapping spans in a text.")
254
+
255
+ with gr.Row():
256
+ with gr.Column():
257
+ span1 = gr.Textbox(
258
+ label="Span 1", value="U.K. startup", placeholder="Input a part of the sentence")
259
+ with gr.Column():
260
+ label1 = gr.Textbox(value="ORG",
261
+ label="Label for Span 1")
262
+ with gr.Column():
263
+ gr.Markdown("")
264
+ with gr.Column():
265
+ gr.Markdown("")
266
+ with gr.Row():
267
+ with gr.Column():
268
+ span2 = gr.Textbox(
269
+ label="Span 2", value="U.K.", placeholder="Input another part of the sentence")
270
+ with gr.Column():
271
+ label2 = gr.Textbox(value="GPE",
272
+ label="Label for Span 2")
273
+ with gr.Column():
274
+ gr.Markdown("")
275
+ with gr.Column():
276
+ gr.Markdown("")
277
+ span_output = gr.HTML(value=span(
278
+ DEFAULT_TEXT, "U.K. startup", "U.K.", "ORG", "GPE", DEFAULT_MODEL))
279
+ gr.Markdown(value="")
280
+ gr.Markdown(value="")
281
+ span_button = gr.Button("Generate spans")
282
 
283
  model_input.change(get_text, inputs=[model_input], outputs=text_input)
284
  button.click(dependency, inputs=[