awacke1 commited on
Commit
46b15c1
1 Parent(s): 199971f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -67
app.py CHANGED
@@ -198,12 +198,6 @@ def group_by_entity(raw):
198
  except ValueError as err:
199
  raise ValueError("Error in group by entity \n" + format_tb(err.__traceback__)[0] + err.args[0] + "\nEnd of error message.") from None
200
 
201
- #print(sAll)
202
-
203
- #return out;
204
- #break;
205
- # out["total"] = sum(out.values())
206
- # return out
207
  return outputFile
208
 
209
 
@@ -232,27 +226,11 @@ def ner(text):
232
  ],
233
  }
234
 
235
- #grouped = group_by_entity(raw)
236
  outputFile = group_by_entity(raw)
237
-
238
- #figure = plot_to_figure(grouped)
239
-
240
  label = EXAMPLES.get(text, "Unknown")
241
-
242
- #meta = {
243
- # "entity_counts": grouped,
244
- # "entities": len(set(grouped.keys())),
245
- # "counts": sum(grouped.values()),
246
- # }
247
-
248
- #return (ner_content, meta, label, figure)
249
  outputDataframe = pd.read_csv(outputFile)
250
- #outputFile = outputFile.replace(os.path.dirname(__file__) + "\\","") # Just filename for File download UI output element
251
-
252
- #return (ner_content, meta, label, figure, outputDataframe, outputFile)
253
  return (ner_content, outputDataframe, outputFile)
254
 
255
- # New way = Gradio Blocks:
256
  demo = gr.Blocks()
257
  with demo:
258
  gr.Markdown(
@@ -261,9 +239,7 @@ with demo:
261
  """
262
  )
263
  input = gr.Textbox(label="Note text", value="")
264
- #output=[
265
- # gr.HighlightedText(label="NER", combine_adjacent=True)
266
- #]
267
  with gr.Tab("Biomedical Entity Recognition"):
268
  output=[
269
  gr.HighlightedText(label="NER", combine_adjacent=True),
@@ -276,10 +252,8 @@ with demo:
276
  examples=list(EXAMPLES.keys())
277
  gr.Examples(examples, inputs=input)
278
  input.change(fn=ner, inputs=input, outputs=output)
 
279
  with gr.Tab("Clinical Terminology Resolution"):
280
- #output=[
281
- # gr.Textbox(placeholder="CT Match Results", lines=10)
282
- #]
283
  with gr.Row(variant="compact"):
284
  btnLOINC = gr.Button("LOINC")
285
  btnPanels = gr.Button("Panels")
@@ -287,46 +261,8 @@ with demo:
287
  btnOMS = gr.Button("OMS")
288
  btnICD10 = gr.Button("ICD10")
289
 
290
- #output=[
291
- # gr.HighlightedText(label="NER", combine_adjacent=True),
292
- # gr.File(label="File"), # add download link here
293
- # gr.Dataframe(label="Dataframe", headers=["LOINC", "Panels", "SNOMED", "OMS", "ICD10"]), # add harmonised output for input corpus here as a dataframe to UI
294
- # gr.Textbox(placeholder="CT Match Results", lines=10) # add matched text scratchpad here
295
- #]
296
-
297
-
298
- #textCT = gr.Textbox(placeholder="CT Match Results", lines=10)
299
-
300
- #btnLOINC.click(loadFile, inputs=["LOINCTerms.txt"], outputs=output)
301
- #btnPanels.click(loadFile, "LOINCPanelsandForms.txt", output)
302
- #btnSNOMED.click(loadFile, "SNOMEDTerms.txt", output)
303
- #btnOMS.click(loadFile, "OMSTerms.txt", output)
304
- #btnICD10.click(loadFile, "ICD10Terms.txt", output)
305
-
306
  examples=list(EXAMPLES.keys())
307
  gr.Examples(examples, inputs=input)
308
  input.change(fn=ner, inputs=input, outputs=output)
309
- #with gr.Tab("Examples Page 1"):
310
- # gr.Examples(["a", "b", "c"], inputs=input)
311
- #with gr.Tab("Examples Page 2"):
312
- # gr.Examples(["d", "e", "f"], inputs=input)
313
- #with gr.Tab("Examples Page 2"):
314
- # gr.Examples(["g", "h", "i"], inputs=input)
315
-
316
  demo.launch(debug=True)
317
-
318
- # Old Way - Interface Load
319
- #interface = gr.Interface(
320
- # ner,
321
- # inputs=gr.Textbox(label="Note text", value=""),
322
- # outputs=[
323
- # gr.HighlightedText(label="NER", combine_adjacent=True),
324
- # gr.JSON(label="Entity Counts"),
325
- # gr.Label(label="Rating"),
326
- # gr.Plot(label="Bar"),
327
- # ],
328
- # examples=list(EXAMPLES.keys()),
329
- # allow_flagging="never",
330
- #)
331
-
332
- #interface.launch()
 
198
  except ValueError as err:
199
  raise ValueError("Error in group by entity \n" + format_tb(err.__traceback__)[0] + err.args[0] + "\nEnd of error message.") from None
200
 
 
 
 
 
 
 
201
  return outputFile
202
 
203
 
 
226
  ],
227
  }
228
 
 
229
  outputFile = group_by_entity(raw)
 
 
 
230
  label = EXAMPLES.get(text, "Unknown")
 
 
 
 
 
 
 
 
231
  outputDataframe = pd.read_csv(outputFile)
 
 
 
232
  return (ner_content, outputDataframe, outputFile)
233
 
 
234
  demo = gr.Blocks()
235
  with demo:
236
  gr.Markdown(
 
239
  """
240
  )
241
  input = gr.Textbox(label="Note text", value="")
242
+
 
 
243
  with gr.Tab("Biomedical Entity Recognition"):
244
  output=[
245
  gr.HighlightedText(label="NER", combine_adjacent=True),
 
252
  examples=list(EXAMPLES.keys())
253
  gr.Examples(examples, inputs=input)
254
  input.change(fn=ner, inputs=input, outputs=output)
255
+
256
  with gr.Tab("Clinical Terminology Resolution"):
 
 
 
257
  with gr.Row(variant="compact"):
258
  btnLOINC = gr.Button("LOINC")
259
  btnPanels = gr.Button("Panels")
 
261
  btnOMS = gr.Button("OMS")
262
  btnICD10 = gr.Button("ICD10")
263
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
264
  examples=list(EXAMPLES.keys())
265
  gr.Examples(examples, inputs=input)
266
  input.change(fn=ner, inputs=input, outputs=output)
267
+ #layout="vertical"
 
 
 
 
 
 
268
  demo.launch(debug=True)