SHARE
TWEET

Python - spacy - render svg

furas Jun 15th, 2018 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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')
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top