explosion / spacy-streamlit

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

Getting text or disabling text box from .visualizer #18

Closed ritchieng closed 3 years ago

ritchieng commented 3 years ago

When you use:

spacy_streamlit.visualize()

How do you get the textual data input into the text box? Can we disable that text box and feed directly into visualize instead?

polm commented 3 years ago

I'm not really clear what you're asking. Do you want to get the text in a variable like st.text() or something?

If you want to show the visualization with no text input you can just use one of the helpers directly, something like this:

import spacy
import spacy_streamlit

nlp = spacy.load("en_core_web_sm")
doc = nlp("This is a text")
spacy_streamlit.visualize_parser(doc)
polm commented 3 years ago

Closing due to lack of reply, but feel free to respond if you see this later.