split bigram counting code from text generation code