in reply to Word density
As jdporter wisely said, you don't want to go reinventing this particular wheel.
With that in mind, may I suggest Ted Pedersen's Ngram Statistics Package?
HTH,