jschwaller commited on
Commit
f0b4ad9
·
verified ·
1 Parent(s): a76acd6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -1
app.py CHANGED
@@ -69,6 +69,21 @@ def main(prob1):
69
  text = str(prob1).lower()
70
  obj = adr_predict(text)
71
  return obj[0], obj[1], obj[2]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
 
73
  title = "Welcome to **ADR Tracker**"
74
  description1 = "This app takes text (up to a few sentences) and predicts to what extent the text describes severe (or non-severe) adverse reaction to medications. Please do NOT use for medical diagnosis."
@@ -100,7 +115,10 @@ with gr.Blocks(css=css) as demo:
100
  [label, local_plot, htext],
101
  api_name="adr"
102
  )
103
-
 
 
 
104
  with gr.Row():
105
  gr.Markdown("### Click on any of the examples below to see how it works:")
106
  gr.Examples([["A 35 year-old male had severe headache after taking Aspirin. The lab results were normal."],
@@ -108,3 +126,4 @@ with gr.Blocks(css=css) as demo:
108
  [prob1], [label, local_plot, htext], main, cache_examples=True)
109
 
110
  demo.launch()
 
 
69
  text = str(prob1).lower()
70
  obj = adr_predict(text)
71
  return obj[0], obj[1], obj[2]
72
+
73
+ # Define HTML for the legend
74
+ legend_html = """
75
+ <div style='margin-top: 20px;'>
76
+ <h3>NER Legend</h3>
77
+ <ul style='list-style-type:none;'>
78
+ """
79
+
80
+ for entity, color in entity_colors.items():
81
+ legend_html += f"<li><span style='color:{color}; font-weight:bold;'>▉ </span>{entity}</li>"
82
+
83
+ legend_html += "</ul></div>"
84
+
85
+ # Create a Gradio HTML component to display the legend
86
+ ner_legend = gr.HTML(value=legend_html)
87
 
88
  title = "Welcome to **ADR Tracker**"
89
  description1 = "This app takes text (up to a few sentences) and predicts to what extent the text describes severe (or non-severe) adverse reaction to medications. Please do NOT use for medical diagnosis."
 
115
  [label, local_plot, htext],
116
  api_name="adr"
117
  )
118
+
119
+ # Display the NER Legend below the buttons
120
+ ner_legend # Assuming you've defined this component above as shown
121
+
122
  with gr.Row():
123
  gr.Markdown("### Click on any of the examples below to see how it works:")
124
  gr.Examples([["A 35 year-old male had severe headache after taking Aspirin. The lab results were normal."],
 
126
  [prob1], [label, local_plot, htext], main, cache_examples=True)
127
 
128
  demo.launch()
129
+