riccorl commited on
Commit
8745a5f
1 Parent(s): d47ab1c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -123,7 +123,14 @@ def set_sidebar(css):
123
 
124
  def get_el_annotations(response):
125
  # swap labels key with ents
126
- ents = [{"start": l.start, "end": l.end, "label": l.label} for l in response.labels]
 
 
 
 
 
 
 
127
  dict_of_ents = {"text": response.text, "ents": ents}
128
  label_in_text = set(l["label"] for l in dict_of_ents["ents"])
129
  options = {"ents": label_in_text, "colors": get_random_color(label_in_text)}
@@ -228,13 +235,6 @@ def run_client():
228
  dict_of_ents, manual=True, style="ent", options=options
229
  )
230
  display = display.replace("\n", " ")
231
- # wsd_display = re.sub(
232
- # r"(wiki::\d+\w)",
233
- # r"<a href='https://babelnet.org/synset?id=\g<1>&orig=\g<1>&lang={}'>\g<1></a>".format(
234
- # language.upper()
235
- # ),
236
- # wsd_display,
237
- # )
238
  with st.container():
239
  st.write(display, unsafe_allow_html=True)
240
 
 
123
 
124
  def get_el_annotations(response):
125
  # swap labels key with ents
126
+ ents = [
127
+ {
128
+ "start": l.start,
129
+ "end": l.end,
130
+ "label": f"<a href='https://en.wikipedia.org/wiki/{l.label.replace(' ', '_')}' style='color: #222222'>{l.label}</a>",
131
+ }
132
+ for l in response.labels
133
+ ]
134
  dict_of_ents = {"text": response.text, "ents": ents}
135
  label_in_text = set(l["label"] for l in dict_of_ents["ents"])
136
  options = {"ents": label_in_text, "colors": get_random_color(label_in_text)}
 
235
  dict_of_ents, manual=True, style="ent", options=options
236
  )
237
  display = display.replace("\n", " ")
 
 
 
 
 
 
 
238
  with st.container():
239
  st.write(display, unsafe_allow_html=True)
240