lterriel commited on
Commit
8c415e5
Β·
1 Parent(s): fd24d85

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -10
app.py CHANGED
@@ -4,14 +4,13 @@ import json
4
  import requests
5
 
6
  import streamlit
7
- import spacy_streamlit
8
  import spacy
9
  from lxml import etree
10
  import pandas as pd
11
 
12
  # Constants
13
  CONFIG_FILE = "config.json"
14
- ASSETS_DIR = "./assets"
15
  XML_PARSER_CONFIG = {'ns_clean': True, 'recover': True, 'encoding': 'utf-8'}
16
  ENTITY_COLORS = {
17
  "EVENT": "#ec7063",
@@ -105,7 +104,7 @@ def main():
105
  entities = []
106
  # 1. User provides a XML EAD
107
  streamlit.write("## πŸ“„ Input XML EAD:")
108
- filename = streamlit.file_uploader("Upload an XML EAD (format .xml)", type="xml")
109
  streamlit.markdown(
110
  "or use an XML EAD provided in [`samples/`](https://huggingface.co/spaces/ner4archives/ner4archives-NEL-vizualizer-app/blob/main/samples/) directory")
111
 
@@ -220,21 +219,21 @@ def main():
220
  streamlit.write(df)
221
 
222
  streamlit.write("## πŸ”Ž Explore named entities in text: ")
223
- spacy_streamlit.visualize_ner(
224
- {"text": plain,
225
  "ents": [{"start": ent[0],
226
  "end": ent[1],
227
  "label": ent[3],
228
  "kb_id": ent[4] if linking else "",
229
  "kb_url": ent[5] if linking else ""
230
- } for ent in entities]},
231
- labels=["EVENT", "LOCATION", "ORGANISATION", "PERSON", "TITLE", 'LOC', 'MISC', 'ORG', 'PER'],
232
- show_table=False,
233
  manual=True,
234
- title="",
235
- displacy_options={
236
  "colors": ENTITY_COLORS
237
  })
 
238
 
239
 
240
  if __name__ == "__main__":
 
4
  import requests
5
 
6
  import streamlit
 
7
  import spacy
8
  from lxml import etree
9
  import pandas as pd
10
 
11
  # Constants
12
  CONFIG_FILE = "config.json"
13
+ ASSETS_DIR = "assets"
14
  XML_PARSER_CONFIG = {'ns_clean': True, 'recover': True, 'encoding': 'utf-8'}
15
  ENTITY_COLORS = {
16
  "EVENT": "#ec7063",
 
104
  entities = []
105
  # 1. User provides a XML EAD
106
  streamlit.write("## πŸ“„ Input XML EAD:")
107
+ filename = streamlit.file_uploader("Upload an XML EAD (format .xml)", type="xml", label_visibility="collapsed")
108
  streamlit.markdown(
109
  "or use an XML EAD provided in [`samples/`](https://huggingface.co/spaces/ner4archives/ner4archives-NEL-vizualizer-app/blob/main/samples/) directory")
110
 
 
219
  streamlit.write(df)
220
 
221
  streamlit.write("## πŸ”Ž Explore named entities in text: ")
222
+ ents_html = spacy.displacy.render(
223
+ [{"text": plain,
224
  "ents": [{"start": ent[0],
225
  "end": ent[1],
226
  "label": ent[3],
227
  "kb_id": ent[4] if linking else "",
228
  "kb_url": ent[5] if linking else ""
229
+ } for ent in entities]}],
230
+ style="ent",
 
231
  manual=True,
232
+ options={
233
+ "ents":["EVENT", "LOCATION", "ORGANISATION", "PERSON", "TITLE", 'LOC', 'MISC', 'ORG', 'PER'],
234
  "colors": ENTITY_COLORS
235
  })
236
+ streamlit.markdown(ents_html, unsafe_allow_html=True)
237
 
238
 
239
  if __name__ == "__main__":