Francis Gonzales
Francis Gonzales

Reputation: 495

Displacy from spacy in google colab

I'm trying to run a displacy server in google colab:

from spacy import displacy

frasesin=nlp("Yo quisiera saber porqué el jugador hizo tan mala jugada")

dep=[]
for x in range(1,len(frasesin)):
    dep.append([ frasesin[x].text, frasesin[x].dep_, frasesin[x].head.text])

dep
displacy.serve(frasesin, style="dep")

And it is running fine:

Using the 'dep' visualizer
Serving on http://0.0.0.0:5000 ...

But how can I access this port in colab to see the results?

Upvotes: 12

Views: 7606

Answers (2)

Marc Stogaitis
Marc Stogaitis

Reputation: 957

Use displacy.render instead of .serve, and set jupyter=True

from spacy import displacy

displacy.render(doc, style='dep', jupyter=True, options={'distance': 90})

Upvotes: 36

Roger Bagué
Roger Bagué

Reputation: 21

I had the same issue. Try this: http://localhost:5000/ It worked for me

Upvotes: 2

Related Questions