Here's a Mark V. Chaney text generator in 16 lines of quasi-functional Ruby. Considerably simpler than the table method. if you keep all successors to a word (including duplicates) in an array, any random selection of the array works. No need to compute probabilities.
https://gist.github.com/michaelfeathers/2cf9e1599e06d0563f2e