title: How do I do dependency parsing in NLTK?
body: <p>Going through the NLTK book, it's not clear how to generate a dependency tree from a given sentence.</p>
  
  <p>The relevant section of the book: <a href="https://www.nltk.org/book/ch08.html#dependencies-and-dependency-grammar" rel="noreferrer">sub-chapter on dependency grammar</a> gives an <a href="https://www.nltk.org/book/ch08.html#fig-depgraph0" rel="noreferrer">example figure</a> but it doesn't show how to parse a sentence to come up with those relationships - or maybe I'm missing something fundamental in NLP?</p>
  
  <p><strong>EDIT:</strong>
  I want something similar to what the <a href="http://nlp.stanford.edu:8080/parser/" rel="noreferrer">stanford parser</a> does:
  Given a sentence "I shot an elephant in my sleep", it should return something like:</p>
  
  <pre><code>nsubj(shot-2, I-1)
  det(elephant-4, an-3)
  dobj(shot-2, elephant-4)
  prep(shot-2, in-5)
  poss(sleep-7, my-6)
  pobj(in-5, sleep-7)
  </code></pre>