IFMedTechdemo commited on
Commit
72563c0
·
verified ·
1 Parent(s): 4cebad3

Improve UI: increase NER output size, add auto-resize to input, reorganize examples

Browse files
Files changed (1) hide show
  1. app.py +21 -8
app.py CHANGED
@@ -1,6 +1,5 @@
1
  import json
2
  from collections import Counter
3
-
4
  import matplotlib.pyplot as plt
5
  import gradio as gr
6
  import pandas as pd
@@ -47,17 +46,31 @@ def run_ner(text):
47
  figure = plot_to_figure(grouped)
48
  return ner_content, rows, figure
49
 
50
- with gr.Blocks() as demo:
51
- note = gr.Textbox(label="Note text", lines=8, max_lines=16)
 
 
 
 
 
 
 
 
 
52
  submit = gr.Button("Submit")
53
  gr.Markdown("**Examples:**")
54
- with gr.Row():
55
- for example in examples:
56
- gr.Button(example).click(lambda e=example: e, outputs=note)
57
- highlight = gr.HighlightedText(label="NER", combine_adjacent=True)
 
 
 
 
 
58
  table = gr.Dataframe(headers=["Entity", "Count"])
59
  plot = gr.Plot(label="Bar")
60
  submit.click(run_ner, [note], [highlight, table, plot])
61
  note.submit(run_ner, [note], [highlight, table, plot])
62
 
63
- demo.launch()
 
1
  import json
2
  from collections import Counter
 
3
  import matplotlib.pyplot as plt
4
  import gradio as gr
5
  import pandas as pd
 
46
  figure = plot_to_figure(grouped)
47
  return ner_content, rows, figure
48
 
49
+ # Custom CSS to increase NER output size
50
+ custom_css = """
51
+ #ner-output {
52
+ min-height: 400px !important;
53
+ max-height: 600px !important;
54
+ overflow-y: auto !important;
55
+ }
56
+ """
57
+
58
+ with gr.Blocks(css=custom_css) as demo:
59
+ note = gr.Textbox(label="Note text", lines=8, max_lines=None, autoscroll=False)
60
  submit = gr.Button("Submit")
61
  gr.Markdown("**Examples:**")
62
+ # Rearrange examples - display them in a cleaner column layout
63
+ with gr.Column():
64
+ for i in range(0, len(examples), 2):
65
+ with gr.Row():
66
+ for j in range(2):
67
+ if i + j < len(examples):
68
+ example = examples[i + j]
69
+ gr.Button(example).click(lambda e=example: e, outputs=note)
70
+ highlight = gr.HighlightedText(label="NER", combine_adjacent=True, show_legend=True, elem_id="ner-output")
71
  table = gr.Dataframe(headers=["Entity", "Count"])
72
  plot = gr.Plot(label="Bar")
73
  submit.click(run_ner, [note], [highlight, table, plot])
74
  note.submit(run_ner, [note], [highlight, table, plot])
75
 
76
+ demo.launch()