mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-26 01:46:28 +03:00
Make enabling/disabling jupyter mode more explicit (#4144)
* make enabling/disabling jupyter mode more explicit * markup fix
This commit is contained in:
parent
434f6fa6c1
commit
cc66f47893
|
@ -201,11 +201,14 @@ doc2 = nlp(LONG_NEWS_ARTICLE)
|
||||||
displacy.render(doc2, style="ent")
|
displacy.render(doc2, style="ent")
|
||||||
```
|
```
|
||||||
|
|
||||||
> #### Enabling or disabling Jupyter mode
|
<Infobox variant="warning" title="Important note">
|
||||||
>
|
|
||||||
> To explicitly enable or disable "Jupyter mode", you can use the jupyter`
|
To explicitly enable or disable "Jupyter mode", you can use the `jupyter`
|
||||||
> keyword argument – e.g. to return raw HTML in a notebook, or to force Jupyter
|
keyword argument – e.g. to return raw HTML in a notebook, or to force Jupyter
|
||||||
> rendering if auto-detection fails.
|
rendering if auto-detection fails.
|
||||||
|
|
||||||
|
</Infobox>
|
||||||
|
|
||||||
|
|
||||||
![displaCy visualizer in a Jupyter notebook](../images/displacy_jupyter.jpg)
|
![displaCy visualizer in a Jupyter notebook](../images/displacy_jupyter.jpg)
|
||||||
|
|
||||||
|
@ -281,7 +284,7 @@ nlp = spacy.load("en_core_web_sm")
|
||||||
sentences = [u"This is an example.", u"This is another one."]
|
sentences = [u"This is an example.", u"This is another one."]
|
||||||
for sent in sentences:
|
for sent in sentences:
|
||||||
doc = nlp(sent)
|
doc = nlp(sent)
|
||||||
svg = displacy.render(doc, style="dep")
|
svg = displacy.render(doc, style="dep", jupyter=False)
|
||||||
file_name = '-'.join([w.text for w in doc if not w.is_punct]) + ".svg"
|
file_name = '-'.join([w.text for w in doc if not w.is_punct]) + ".svg"
|
||||||
output_path = Path("/images/" + file_name)
|
output_path = Path("/images/" + file_name)
|
||||||
output_path.open("w", encoding="utf-8").write(svg)
|
output_path.open("w", encoding="utf-8").write(svg)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user