Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display <IPython.core.display.HTML object> in Spark

I am trying to display Spacy Dependency Tree in Pyspark (Databricks). But I am getting this error. Could someone help me with the display of html object please. I am attaching screenshot of the Error message. Thanks in advance. Here is my code:

import spacy
from spacy import displacy

doc = nlp("Reliance is looking at buying U.K. based analytics startup for $7 billion")
displacy.render(doc, style="dep" , jupyter=True)

Error message: enter image description here

like image 384
Gargi Nirmal Avatar asked Jul 30 '26 10:07

Gargi Nirmal


1 Answers

This won't work in the Databricks notebooks, because it's not an Jupyter. But you can use displayHTML function together with rendering as HTML:

displayHTML(displacy.render(doc, style="dep", page=True))

Or even display SVG data directly:

displayHTML(displacy.render(doc, style="dep"))

here is result:

enter image description here

like image 139
Alex Ott Avatar answered Aug 02 '26 06:08

Alex Ott



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!