title: Understanding the `ngram_range` argument in a CountVectorizer in sklearn
body: <p>I'm a little confused about how to use ngrams in the scikit-learn library in Python, specifically, how the <code>ngram_range</code> argument works in a CountVectorizer.  </p>
  
  <p>Running this code:  </p>
  
  <pre><code>from sklearn.feature_extraction.text import CountVectorizer
  vocabulary = ['hi ', 'bye', 'run away']
  cv = CountVectorizer(vocabulary=vocabulary, ngram_range=(1, 2))
  print cv.vocabulary_
  </code></pre>
  
  <p>gives me:  </p>
  
  <pre><code>{'hi ': 0, 'bye': 1, 'run away': 2}
  </code></pre>
  
  <p>Where I was under the (obviously mistaken) impression that I would get unigrams and bigrams, like this:  </p>
  
  <pre><code>{'hi ': 0, 'bye': 1, 'run away': 2, 'run': 3, 'away': 4}
  </code></pre>
  
  <p>I am working with the documentation here:  <a href="http://scikit-learn.org/stable/modules/feature_extraction.html">http://scikit-learn.org/stable/modules/feature_extraction.html</a></p>
  
  <p>Clearly there is something terribly wrong with my understanding of how to use ngrams.  Perhaps the argument is having no effect or I have some conceptual issue with what an actual bigram is!  I'm stumped.  If anyone has a word of advice to throw my way, I'd be grateful.  </p>
  
  <p><strong>UPDATE:</strong><br>
  I have realized the folly of my ways. I was under the impression that the <code>ngram_range</code> would affect the vocabulary, not the corpus.</p>