I'm trying to build an n-gram markov model from a given piece of text, and then access the transition table for it so I can calculate the conditional entropy for each sequence of words of length n (the grams). For example, in a 2-gram model, after reading in a corpus of text
"dogs chase cats dogs chase cats dogs chase cats dogs chase cats dogs chase cats dogs chase cats dogs chase cats dogs chase cats dogs chase cats dogs chase people"
and building an internal transition table, the state "dogs chase" may transition to the state "chase cats" with probability 0.9, and to state "chase people" with probability 0.1. If I know of the possible transitions, I can calculate the conditional entropy.
Are there any good python libraries for doing this? I've checked NLTK, SRILM, and others but haven't found much.