Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 205
Francis Gonzales Avatar asked Nov 16 '19 15:11

Francis Gonzales


2 Answers

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

from spacy import displacy

displacy.render(doc, style='dep', jupyter=True, options={'distance': 90})
like image 169
Marc Stogaitis Avatar answered Sep 18 '22 13:09

Marc Stogaitis


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

like image 20
Roger Bagué Avatar answered Sep 17 '22 13:09

Roger Bagué