Open
Description
Running the set examples in Jupyter notebook causes:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[47], line 2
1 doc = nlp('The tenants have mobility issues and cannot see well.')
----> 2 spacy_streamlit.visualize_spans(doc,
3 spans_key='sc',
4 displacy_options={'colors': {"MOBILITY":'#09a3d5'}},
5 show_table=False)
File ~\.conda\envs\prodigy\lib\site-packages\spacy_streamlit\visualizer.py:326, in visualize_spans(doc, spans_key, attrs, show_table, title, manual, displacy_options)
317 st.warning(
318 "When the parameter 'manual' is set to True, the parameter 'doc' must be of type 'Dict', not 'spacy.tokens.Doc'."
319 )
320 html = displacy.render(
321 doc,
322 style="span",
323 options=displacy_options,
324 manual=manual,
325 )
--> 326 st.write(f"{get_html(html)}", unsafe_allow_html=True)
328 if show_table:
329 data = [
330 [str(getattr(span, attr)) for attr in attrs]
331 for span in doc.spans[spans_key]
332 ]
File ~\.conda\envs\prodigy\lib\site-packages\spacy_streamlit\util.py:30, in get_html(html)
28 WRAPPER = """<div style="overflow-x: auto; border: 1px solid #e6e9ef; border-radius: 0.25rem; padding: 1rem; margin-bottom: 2.5rem">{}</div>"""
29 # Newlines seem to mess with the rendering
---> 30 html = html.replace("\n", " ")
31 return WRAPPER.format(html)
AttributeError: 'NoneType' object has no attribute 'replace'
Setup:
Windows Server 2019 Standard
Jupyter 1.0.0
spaCy version 3.6.1
spacy-streamlit 1.0.6
Code:
import spacy_streamlit
import streamlit as st
import spacy
from spacy_streamlit import visualize_spans
nlp = spacy.load("en_core_web_sm")
doc = nlp("Sundar Pichai is the CEO of Google.")
span = doc[4:7] # CEO of Google
span.label_ = "CEO"
doc.spans["job_role"] = [span]
visualize_spans(
doc, spans_key="job_role", displacy_options={"colors": {"CEO": "#09a3d5"}}
)
Metadata
Metadata
Assignees
Labels
No labels