title: How to find position of an ngram in a sentence?
body: <p><strong>Is there a way to find the first position of an ngram in a sentence?</strong></p>
  
  <pre><code>&gt;&gt;&gt; from nltk import ngrams
  &gt;&gt;&gt; hyp = ['he', 'read', 'the', 'book', 'because', 'he', 'was', 'interested', 'in', 'world', 'history']
  &gt;&gt;&gt; position_of_ngram(('the', 'book'), hyp)
  2
  </code></pre>
  
  <p>Currently, I'm using some string hacks:</p>
  
  <pre><code>&gt;&gt;&gt; " ".join(hyp)[:" ".join(hyp).index(" ".join(('the', 'book')))].count(' ')
  2
  </code></pre>
  
  <p>But <strong>is there a way to do it without silly string conversions?</strong> If so, is that a faster way compared to the "string/regex hack"?</p>