Vscode-jupyter: Jupyter notebook can't render displacy

Created on 4 May 2020  路  5Comments  路  Source: microsoft/vscode-jupyter

Issue Type: Bug

DisplaCy (from the spaCy module) supports rendering in Jupyter notebooks, but the notebook features in VS Code's Python extension fail to render these outputs.

Extension version: 2020.4.76186
VS Code version: Code 1.44.2 (ff915844119ce9485abfe8aa9076ec76b5300ddd, 2020-04-16T17:07:18.473Z)
OS version: Darwin x64 19.4.0

bug

All 5 comments

Thank you for your feedback @pbadeer. Could you please share the notebook that uses DisplaCy and has the issue? It doesn't have to be your actual work, just a notebook that showcases the issue.

Any example you can find, here's the one in the docs.

import spacy
from spacy import displacy

text = "When Sebastian Thrun started working on self-driving cars at Google in 2007, few people outside of the company took him seriously."

nlp = spacy.load("en_core_web_sm")
doc = nlp(text)
displacy.serve(doc, style="ent")

Thanks @pbadeer, that's very helpful. I'm having trouble working with spacy on its own. We'll discuss this bug on our next triage.

@pbadeer you should use render with param jupyter = True besides serve

import spacy
from spacy import displacy

text = "When Sebastian Thrun started working on self-driving cars at Google in 2007, few people outside of the company took him seriously."

nlp = spacy.load("en_core_web_sm")
doc = nlp(text)
displacy.render(doc, style="ent", jupyter = True)

image

Reference: https://github.com/explosion/spaCy/issues/2666#issuecomment-412906622

Looks like a workaround/fix has been provided.

Was this page helpful?
0 / 5 - 0 ratings