'Making a biagram table from Corpus

i am trying to make a biagram table from a corpus with a text file which contains 100 sentences but i am unable to do it. right now i only have code with showing how many sentences that text file has. I am new to machine translation and couldnt work it out from NLTK packages. Can anyone help? thanks

from nltk.corpus.reader import WordListCorpusReader

reader = nltk.corpus.PlaintextCorpusReader('.', ['100sentence.txt'])

print ("The number of sentences =", len(reader.sents()))

basically what i want to do is make a biagram table from my txt file and being able to count words that i want from the text file



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source