title: Building a more realistic random word generator?
body: <p>I'm seen many examples of using <a href="http://en.wikipedia.org/wiki/Markov_chain" rel="noreferrer">Markov chains</a> for generating random words based on source data, but they often seem a bit overly mechanical and abstract to me. I'm trying to develop a better one.</p>
  
  <p>I believe part of the problem is that they rely entirely on the overall statistical occurrence of pairs, and ignore the tendency of words to start and end in certain ways.  For example, if you use the top 1000 baby names as source data, the letter J is relatively rare overall, yet it's the second most common letter for names to <em>start</em> with.  Or, if you're using Latin source data, word endings like -um and -us would be common <em>endings</em>, but not as common if you consider all pairs the same.</p>
  
  <p>So, I'm basically trying to put together a Markov chain based word generator that takes into account the way words start and end in the source data.</p>
  
  <p>Conceptually, that makes sense to me, yet I can't figure out how to implement this from a software perspective. I'm trying to put together a little PHP tool that allows you to drop in source data (e.g., a list of 1000 words) from which it will then generate a variety of random words with realistic starts, middles, and endings. (As opposed to most Markov-based word generators, which are just based on the statistical occurrence of pairs overall.)</p>
  
  <p>I'd also like to do this with word length determined by the source data, if possible; i.e., the length breakdown of the randomly generated words should be approximately the same as the length breakdown of the source data.</p>
  
  <p>Any ideas would be massively appreciated! Thanks.</p>