Advertisement
furas

Python - spacy - render svg

Jun 15th, 2018
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.29 KB | None | 0 0
  1. import spacy
  2. import webbrowser
  3.  
  4. nlp = spacy.load('en')
  5. doc = nlp(u'This is a sentence.')
  6.  
  7. html = spacy.displacy.render(doc, style='dep')
  8.  
  9. with open('temp.svg', 'w') as f:
  10.     f.write(html)
  11.  
  12. # open in default program
  13. # (it doesn't have to be web browser)
  14. webbrowser.open('temp.svg')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement