mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 09:26:27 +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 #[code jupyter]
|
||||||
+cell bool
|
+cell bool
|
||||||
+cell
|
+cell
|
||||||
| Returns markup using #[+a("http://jupyter.org/") Jupyter]'s
|
| Explicitly enable "#[+a("http://jupyter.org/") Jupyter] mode" to
|
||||||
| internal methods, ready to be rendered in a notebook.
|
| return markup ready to be rendered in a notebook.
|
||||||
+cell #[code False]
|
+cell detected automatically
|
||||||
|
|
||||||
+row
|
+row
|
||||||
+cell #[code options]
|
+cell #[code options]
|
||||||
|
|
|
@ -11,8 +11,12 @@ p
|
||||||
| process. Instead of printing a list of dependency labels or entity spans,
|
| 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
|
| 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
|
| the visualizations in your browser, or export them as HTML files or
|
||||||
| vector graphics. displaCy also comes with a #[+a("#jupyter") Jupyter hook]
|
| vector graphics.
|
||||||
| that returns the markup in a format ready to be rendered in a notebook.
|
|
||||||
|
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?")
|
+aside("What about the old visualizers?")
|
||||||
| Our JavaScript-based visualizers #[+src(gh("displacy")) displacy.js] and
|
| Our JavaScript-based visualizers #[+src(gh("displacy")) displacy.js] and
|
||||||
|
@ -219,10 +223,10 @@ p
|
||||||
+h(2, "jupyter") Using displaCy in Jupyter notebooks
|
+h(2, "jupyter") Using displaCy in Jupyter notebooks
|
||||||
|
|
||||||
p
|
p
|
||||||
| If you're working with a #[+a("https://jupyter.org") Jupyter] notebook,
|
| displaCy is able to detect whether you're within a
|
||||||
| you can use displaCy's "Jupyter mode" to return markup that can be
|
| #[+a("https://jupyter.org") Jupyter] notebook, and will return markup
|
||||||
| rendered in a cell straight away. When you export your notebook, the
|
| that can be rendered in a cell straight away. When you export your
|
||||||
| visualizations will be included as HTML.
|
| notebook, the visualizations will be included as HTML.
|
||||||
|
|
||||||
+code("Jupyter Example").
|
+code("Jupyter Example").
|
||||||
# don't forget to install a model, e.g.: python -m spacy download en
|
# don't forget to install a model, e.g.: python -m spacy download en
|
||||||
|
@ -230,10 +234,15 @@ p
|
||||||
from spacy import displacy
|
from spacy import displacy
|
||||||
|
|
||||||
doc = nlp(u'Rats are various medium-sized, long-tailed rodents.')
|
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)
|
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")
|
+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