mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 01:16:28 +03:00
Update docs with new Jupyter auto-detection
This commit is contained in:
parent
489d2fb4ba
commit
476b8209fe
|
@ -101,9 +101,9 @@ p Render a dependency parse tree or named entity visualization.
|
|||
+cell #[code jupyter]
|
||||
+cell bool
|
||||
+cell
|
||||
| Returns markup using #[+a("http://jupyter.org/") Jupyter]'s
|
||||
| internal methods, ready to be rendered in a notebook.
|
||||
+cell #[code False]
|
||||
| Explicitly enable "#[+a("http://jupyter.org/") Jupyter] mode" to
|
||||
| return markup ready to be rendered in a notebook.
|
||||
+cell detected automatically
|
||||
|
||||
+row
|
||||
+cell #[code options]
|
||||
|
|
|
@ -11,8 +11,12 @@ p
|
|||
| process. Instead of printing a list of dependency labels or entity spans,
|
||||
| you can simply pass your #[code Doc] objects to #[code displacy] and view
|
||||
| the visualizations in your browser, or export them as HTML files or
|
||||
| vector graphics. displaCy also comes with a #[+a("#jupyter") Jupyter hook]
|
||||
| that returns the markup in a format ready to be rendered in a notebook.
|
||||
| vector graphics.
|
||||
|
||||
p
|
||||
| If you're running a #[+a("https://jupyter.org") Jupyter] notebook,
|
||||
| displaCy will detect this and return the markup in a format
|
||||
| #[+a("#jupyter") ready to be rendered and exported].
|
||||
|
||||
+aside("What about the old visualizers?")
|
||||
| Our JavaScript-based visualizers #[+src(gh("displacy")) displacy.js] and
|
||||
|
@ -219,10 +223,10 @@ p
|
|||
+h(2, "jupyter") Using displaCy in Jupyter notebooks
|
||||
|
||||
p
|
||||
| If you're working with a #[+a("https://jupyter.org") Jupyter] notebook,
|
||||
| you can use displaCy's "Jupyter mode" to return markup that can be
|
||||
| rendered in a cell straight away. When you export your notebook, the
|
||||
| visualizations will be included as HTML.
|
||||
| displaCy is able to detect whether you're within a
|
||||
| #[+a("https://jupyter.org") Jupyter] notebook, and will return markup
|
||||
| that can be rendered in a cell straight away. When you export your
|
||||
| notebook, the visualizations will be included as HTML.
|
||||
|
||||
+code("Jupyter Example").
|
||||
# don't forget to install a model, e.g.: python -m spacy download en
|
||||
|
@ -230,10 +234,15 @@ p
|
|||
from spacy import displacy
|
||||
|
||||
doc = nlp(u'Rats are various medium-sized, long-tailed rodents.')
|
||||
displacy.render(doc, style='dep', jupyter=True)
|
||||
displacy.render(doc, style='dep')
|
||||
|
||||
doc2 = nlp(LONG_NEWS_ARTICLE)
|
||||
displacy.render(doc2, style='ent', jupyter=True)
|
||||
displacy.render(doc2, style='ent')
|
||||
|
||||
+aside("Enabling or disabling Jupyter mode")
|
||||
| To explicitly enable or disable "Jupyter mode", you can use the
|
||||
| #[code jupyter] keyword argument – e.g. to return raw HTML in a notebook,
|
||||
| or to force Jupyter rendering if auto-detection fails.
|
||||
|
||||
+image("/assets/img/docs/displacy_jupyter.jpg", 700, false, "Example of using the displaCy dependency and named entity visualizer in a Jupyter notebook")
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user