mirror of
https://github.com/explosion/spaCy.git
synced 2025-07-16 19:22:34 +03:00
Allow jupyter=False to override Jupyter mode (closes #3598)
This commit is contained in:
parent
8e2cef49f3
commit
52658c80d5
|
@ -19,7 +19,7 @@ RENDER_WRAPPER = None
|
||||||
|
|
||||||
|
|
||||||
def render(
|
def render(
|
||||||
docs, style="dep", page=False, minify=False, jupyter=False, options={}, manual=False
|
docs, style="dep", page=False, minify=False, jupyter=None, options={}, manual=False
|
||||||
):
|
):
|
||||||
"""Render displaCy visualisation.
|
"""Render displaCy visualisation.
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ def render(
|
||||||
style (unicode): Visualisation style, 'dep' or 'ent'.
|
style (unicode): Visualisation style, 'dep' or 'ent'.
|
||||||
page (bool): Render markup as full HTML page.
|
page (bool): Render markup as full HTML page.
|
||||||
minify (bool): Minify HTML markup.
|
minify (bool): Minify HTML markup.
|
||||||
jupyter (bool): Experimental, use Jupyter's `display()` to output markup.
|
jupyter (bool): Override Jupyter auto-detection.
|
||||||
options (dict): Visualiser-specific options, e.g. colors.
|
options (dict): Visualiser-specific options, e.g. colors.
|
||||||
manual (bool): Don't parse `Doc` and instead expect a dict/list of dicts.
|
manual (bool): Don't parse `Doc` and instead expect a dict/list of dicts.
|
||||||
RETURNS (unicode): Rendered HTML markup.
|
RETURNS (unicode): Rendered HTML markup.
|
||||||
|
@ -53,7 +53,8 @@ def render(
|
||||||
html = _html["parsed"]
|
html = _html["parsed"]
|
||||||
if RENDER_WRAPPER is not None:
|
if RENDER_WRAPPER is not None:
|
||||||
html = RENDER_WRAPPER(html)
|
html = RENDER_WRAPPER(html)
|
||||||
if jupyter or is_in_jupyter(): # return HTML rendered by IPython display()
|
if jupyter or (jupyter is None and is_in_jupyter()):
|
||||||
|
# return HTML rendered by IPython display()
|
||||||
from IPython.core.display import display, HTML
|
from IPython.core.display import display, HTML
|
||||||
|
|
||||||
return display(HTML(html))
|
return display(HTML(html))
|
||||||
|
|
|
@ -211,16 +211,16 @@ Render a dependency parse tree or named entity visualization.
|
||||||
> html = displacy.render(doc, style="dep")
|
> html = displacy.render(doc, style="dep")
|
||||||
> ```
|
> ```
|
||||||
|
|
||||||
| Name | Type | Description | Default |
|
| Name | Type | Description | Default |
|
||||||
| ----------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ---------------------- |
|
| ----------- | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
|
||||||
| `docs` | list, `Doc`, `Span` | Document(s) to visualize. |
|
| `docs` | list, `Doc`, `Span` | Document(s) to visualize. |
|
||||||
| `style` | unicode | Visualization style, `'dep'` or `'ent'`. | `'dep'` |
|
| `style` | unicode | Visualization style, `'dep'` or `'ent'`. | `'dep'` |
|
||||||
| `page` | bool | Render markup as full HTML page. | `False` |
|
| `page` | bool | Render markup as full HTML page. | `False` |
|
||||||
| `minify` | bool | Minify HTML markup. | `False` |
|
| `minify` | bool | Minify HTML markup. | `False` |
|
||||||
| `jupyter` | bool | Explicitly enable "[Jupyter](http://jupyter.org/) mode" to return markup ready to be rendered in a notebook. | detected automatically |
|
| `jupyter` | bool | Explicitly enable or disable "[Jupyter](http://jupyter.org/) mode" to return markup ready to be rendered in a notebook. Detected automatically if `None`. | `None` |
|
||||||
| `options` | dict | [Visualizer-specific options](#options), e.g. colors. | `{}` |
|
| `options` | dict | [Visualizer-specific options](#options), e.g. colors. | `{}` |
|
||||||
| `manual` | bool | Don't parse `Doc` and instead, expect a dict or list of dicts. [See here](/usage/visualizers#manual-usage) for formats and examples. | `False` |
|
| `manual` | bool | Don't parse `Doc` and instead, expect a dict or list of dicts. [See here](/usage/visualizers#manual-usage) for formats and examples. | `False` |
|
||||||
| **RETURNS** | unicode | Rendered HTML markup. |
|
| **RETURNS** | unicode | Rendered HTML markup. |
|
||||||
|
|
||||||
### Visualizer options {#displacy_options}
|
### Visualizer options {#displacy_options}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user