explosion / spacy-streamlit

👑 spaCy building blocks and visualizers for Streamlit apps
https://share.streamlit.io/ines/spacy-streamlit-demo/master/app.py
MIT License
805 stars 115 forks source link

'NoneType' object has no attribute 'replace' #3

Closed PilarHidalgo closed 3 years ago

PilarHidalgo commented 4 years ago

When I ran the example:

import spacy_streamlit models = ["en_core_web_sm", "en_core_web_md"] default_text = "Sundar Pichai is the CEO of Google." spacy_streamlit.visualize(models, default_text)

Have this problem

AttributeError Traceback (most recent call last)

in 3 models = ["en_core_web_sm", "en_core_web_md"] 4 default_text = "Sundar Pichai is the CEO of Google." ----> 5 spacy_streamlit.visualize(models, default_text) ~/anaconda3/lib/python3.7/site-packages/spacy_streamlit/visualizer.py in visualize(models, default_text, visualizers, ner_labels, ner_attrs, similarity_texts, token_attrs, show_json_doc, show_model_meta, sidebar_title, sidebar_description, show_logo, color) 51 52 if "parser" in visualizers: ---> 53 visualize_parser(doc) 54 if "ner" in visualizers: 55 ner_labels = ner_labels or nlp.get_pipe("ner").labels ~/anaconda3/lib/python3.7/site-packages/spacy_streamlit/visualizer.py in visualize_parser(doc, title, sidebar_title) 98 html = displacy.render(sent, options=options, style="dep") 99 # Double newlines seem to mess with the rendering --> 100 html = html.replace("\n\n", "\n") 101 if split_sents and len(docs) > 1: 102 st.markdown(f"> {sent.text}") AttributeError: 'NoneType' object has no attribute 'replace'
aus10powell commented 4 years ago

It seems like there were no entities detected. Did you try with the medium or large sized Spacy? This has happened before for me.

asriabdelhakim commented 3 years ago

I still have the same problem too, did u use an virtual env? Please i really need you help!!

asriabdelhakim commented 3 years ago

I'm back and I fix it, you should type your code in a python file "example-file.py" and run in command prompt like: streamlit run streamlit_example-file.py

polm commented 3 years ago

As mentioned earlier this seems like just an issue with no entities, so I'll be closing it. If that's not the issue let us know and we can revisit this. (Also sorry for taking so long to reply!)