awacke1 commited on
Commit
02bded3
1 Parent(s): 3eacf29

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -18
app.py CHANGED
@@ -18,11 +18,17 @@ import os
18
 
19
  # Load terminology datasets:
20
  basedir = os.path.dirname(__file__)
21
- dataLOINC = pd.read_csv(basedir + f'LoincTableCore.csv')
22
- dataPanels = pd.read_csv(basedir + f'PanelsAndForms-ACW1208Labeled.csv')
23
- dataSNOMED = pd.read_csv(basedir + f'sct2_TextDefinition_Full-en_US1000124_20220901.txt',sep='\t')
24
- dataOMS = pd.read_csv(basedir + f'SnomedOMS.csv')
25
- dataICD10 = pd.read_csv(basedir + f'ICD10Diagnosis.csv')
 
 
 
 
 
 
26
 
27
  dir_path = os.path.dirname(os.path.realpath(__file__))
28
  EXAMPLES = {}
@@ -168,8 +174,8 @@ def group_by_entity(raw):
168
  if g21 != 'Series([] )': SaveResult(s2, outputFile)
169
 
170
  #SNOMED
171
- g31 = g3['conceptId'].to_string().replace(","," ").replace("\n"," ")
172
- g32 = g3['term'].to_string().replace(","," ").replace("\n"," ")
173
  s3 = ("SNOMED Terms of entity ," + myEntityGroup + ", with term ," + eterm + ", SNOMED concepts of ," + g31 + ", and SNOMED terms of ," + g32 + ", Label,Value, Label,Value, Label,Value ")
174
  if g31 != 'Series([] )': SaveResult(s3, outputFile)
175
 
@@ -240,7 +246,7 @@ def ner(text):
240
 
241
  #return (ner_content, meta, label, figure)
242
  outputDataframe = pd.read_csv(outputFile)
243
- outputFile = outputFile.replace(os.path.dirname(__file__) + "\\","") # Just filename for File download UI output element
244
 
245
  #return (ner_content, meta, label, figure, outputDataframe, outputFile)
246
  return (ner_content, outputDataframe, outputFile)
@@ -250,13 +256,13 @@ demo = gr.Blocks()
250
  with demo:
251
  gr.Markdown(
252
  """
253
- # 🩺⚕️NLP UI for AI Biomedical Entity Type Recognition with Clinical Terminology Harmonisation
254
  """
255
  )
256
  input = gr.Textbox(label="Note text", value="")
257
- output=[
258
- gr.HighlightedText(label="NER", combine_adjacent=True)
259
- ]
260
  with gr.Tab("Biomedical Entity Recognition"):
261
  output=[
262
  gr.HighlightedText(label="NER", combine_adjacent=True),
@@ -280,12 +286,12 @@ with demo:
280
  btnOMS = gr.Button("OMS")
281
  btnICD10 = gr.Button("ICD10")
282
 
283
- output=[
284
- gr.HighlightedText(label="NER", combine_adjacent=True),
285
- gr.File(label="File"), # add download link here
286
- gr.Dataframe(label="Dataframe", headers=["LOINC", "Panels", "SNOMED", "OMS", "ICD10"]), # add harmonised output for input corpus here as a dataframe to UI
287
- gr.Textbox(placeholder="CT Match Results", lines=10) # add matched text scratchpad here
288
- ]
289
 
290
 
291
  #textCT = gr.Textbox(placeholder="CT Match Results", lines=10)
 
18
 
19
  # Load terminology datasets:
20
  basedir = os.path.dirname(__file__)
21
+ #dataLOINC = pd.read_csv(basedir + "\\" + f'LoincTableCore.csv')
22
+ #dataPanels = pd.read_csv(basedir + "\\" + f'PanelsAndForms-ACW1208Labeled.csv')
23
+ #dataSNOMED = pd.read_csv(basedir + "\\" + f'sct2_TextDefinition_Full-en_US1000124_20220901.txt',sep='\t')
24
+ #dataOMS = pd.read_csv(basedir + "\\" + f'SnomedOMS.csv')
25
+ #dataICD10 = pd.read_csv(basedir + "\\" + f'ICD10Diagnosis.csv')
26
+
27
+ dataLOINC = pd.read_csv(f'LoincTableCore.csv')
28
+ dataPanels = pd.read_csv(f'PanelsAndForms-ACW1208Labeled.csv')
29
+ dataSNOMED = pd.read_csv(f'sct2_TextDefinition_Full-en_US1000124_20220901.txt',sep='\t')
30
+ dataOMS = pd.read_csv(f'SnomedOMS.csv')
31
+ dataICD10 = pd.read_csv(f'ICD10Diagnosis.csv')
32
 
33
  dir_path = os.path.dirname(os.path.realpath(__file__))
34
  EXAMPLES = {}
 
174
  if g21 != 'Series([] )': SaveResult(s2, outputFile)
175
 
176
  #SNOMED
177
+ g31 = g3['conceptId'].to_string().replace(","," ").replace("\n"," ").replace("\l"," ").replace("\r"," ")
178
+ g32 = g3['term'].to_string().replace(","," ").replace("\n"," ").replace("\l"," ").replace("\r"," ")
179
  s3 = ("SNOMED Terms of entity ," + myEntityGroup + ", with term ," + eterm + ", SNOMED concepts of ," + g31 + ", and SNOMED terms of ," + g32 + ", Label,Value, Label,Value, Label,Value ")
180
  if g31 != 'Series([] )': SaveResult(s3, outputFile)
181
 
 
246
 
247
  #return (ner_content, meta, label, figure)
248
  outputDataframe = pd.read_csv(outputFile)
249
+ #outputFile = outputFile.replace(os.path.dirname(__file__) + "\\","") # Just filename for File download UI output element
250
 
251
  #return (ner_content, meta, label, figure, outputDataframe, outputFile)
252
  return (ner_content, outputDataframe, outputFile)
 
256
  with demo:
257
  gr.Markdown(
258
  """
259
+ # 🩺⚕️NLP Clinical Ontology Biomedical NER Model
260
  """
261
  )
262
  input = gr.Textbox(label="Note text", value="")
263
+ #output=[
264
+ # gr.HighlightedText(label="NER", combine_adjacent=True)
265
+ #]
266
  with gr.Tab("Biomedical Entity Recognition"):
267
  output=[
268
  gr.HighlightedText(label="NER", combine_adjacent=True),
 
286
  btnOMS = gr.Button("OMS")
287
  btnICD10 = gr.Button("ICD10")
288
 
289
+ #output=[
290
+ # gr.HighlightedText(label="NER", combine_adjacent=True),
291
+ # gr.File(label="File"), # add download link here
292
+ # gr.Dataframe(label="Dataframe", headers=["LOINC", "Panels", "SNOMED", "OMS", "ICD10"]), # add harmonised output for input corpus here as a dataframe to UI
293
+ # gr.Textbox(placeholder="CT Match Results", lines=10) # add matched text scratchpad here
294
+ #]
295
 
296
 
297
  #textCT = gr.Textbox(placeholder="CT Match Results", lines=10)