Reputation: 2946
I want to export displacy graphics as an image file. I run the following code block in Jupyter Notebook and generate an svg file name sample.svg.
The code block is
import spacy
from spacy import displacy
from pathlib import Path
nlp = spacy.load('en_core_web_lg')
sentence_nlp = nlp("John go home to your family")
svg = displacy.render(sentence_nlp, style="ent", jupyter = False)
output_path = Path("D:\\sample.svg")
output_path.open("w", encoding="utf-8").write(svg)
The above code gave me an output 393.
When I try to open the svg file by inserting in powerpoint it shows nothing.
I drag and drop the svg file in the Chrome browser.
The result of drag and drop is as follows
Can any one help me to export the correct svg file format?
Thank you.
Upvotes: 1
Views: 132
Reputation: 504
Mine worked modifying the style
parameter to dep
, so:
svg = displacy.render(sentence_nlp, style="dep", jupyter=False)
Hope it helps!
Upvotes: 0