bigram of a adjacent sentence in python
<p>let's say i have three senteces</p>

<ol>
<li><p>hello world</p></li>
<li><p>hello python</p></li>
<li><p>today is tuesday</p></li>
</ol>

<p>if i generate bigram of this it would generate something like this -</p>

<pre><code>[('hello', 'world')]
[('this', 'is'), ('is', 'python')]
[('today', 'is'), ('is', 'tuesday')]
</code></pre>

<p>basically i want to know is there a difference between bigram for a sentence and bigram for two consecutive sentences. for example "hello world. hello python" is two consecutive sentences. will bigram for this two consecutive sentence look like my output?  </p>

<p>the code that produced it:</p>

<pre><code>   from itertools import tee, izip

   def bigrams(iterable):
            a, b = tee(iterable)
            next(b, None)
            return izip(a, b)

  with open("hello.txt", 'r') as f:
       for line in f:
           words = line.strip().split()
           bi = bigrams(words)
           print list(bi)
</code></pre>
