title: How to print the probability of each bigram in table format
body: <p>The exact format I want to print is like this:</p>
  
  <pre><code>Bigram                                    MLE Prob       Bigram Prob
  "interesting news"                        0.000xxxx        0.000xxx
  "interesting show"                        0.000xxxx        0.000x
  ..(any bigram word set in the text)...
  ....
  ...
  </code></pre>
  
  <p>and below is my code.</p>
  
  <pre><code>from __future__import division
  import re
  import string
  f = open("C:\Python27\text.txt", "rU")
  rawtext = f.read()
  bigrams = {}
  words_punct = rawtext.split()
  words = [ w. strip(string.punctuation).lower() for w in words_punct ]
  words = ["START"] + words + ["END"]
  for index, word in enumerate(words):
      if index &lt; len(words) - 1:
      w1 = words[index] 
      w2 = words[index + 1]
      bigram = (w1, w2)
      if bigram in bigrams:
          bigrams[ bigram ] = bigrams[ bigram ] + 1
      else:
          bigrams[ bigram ] = 1
  
  sorted_bigrams = sorted(bigrams.items(), key = lambda pair:pair[1], reverse = True)
  for bigram, count in sorted_bigrams:
      Bi_Prob = count / sum(list(bigrams.values()))
      print Bi_Prob
  </code></pre>
  
  <p>This gives me the Bi_Prob of each bigram. ( i.e. 0.000xxx, 0.0000xxx, 0.0000x....)
  I don't know well about Python, so I've got lots of help here, and anyway
  I can make the variable MLE Prob soon.. but I'm having hard time printing that result in table format..I tried the tabulate module, like below.</p>
  
  <pre><code>from tabulate import tabulate
  for bigram in sorted_bigrams:
      print tabulate([[bigram]], headers = ['Bigram']
  </code></pre>
  
  <p>something like this...but it doesn't work...that means, using tabulate module, I can get the exact printing result that I uttered previously but it contains only one data. I want some looping result...every bigram, and its probability should be inserted in the table form...</p>
  
  <p>help me and give me some other advices too..</p>
  
  <p>p.s. I didn't use nltk, here. But I installed it anyway. but don't know how to use it. I heard nltk can ease my life...</p>