From: "Kroeger, Simon (ext)" Date: 2006-04-07T23:21:26+09:00 Subject: Re: [QUIZ] Markov Chains (#74) "moby dick - but it was that inscrutable ahab said to have two harpoons and lances, and feel thus intolerably old? close! stand by for it. it is a witchery of social czarship which there was a wilderness of ropes and hawsers chained down to ringbolts" *rofl* this is realy a good one James! Do you have any preferernces for the command line parameters? cheers Simon > -----Original Message----- > From: Charlie Bowman [mailto:charlie@castlebranch.com] > Sent: Friday, April 07, 2006 3:53 PM > To: ruby-talk ML > Subject: Re: [QUIZ] Markov Chains (#74) > > I'm pumped! I've been reading this mailing list for the last 3 months > and I finally feel ready to try out a quiz. This one sounds fun! > > On Fri, 2006-04-07 at 22:02 +0900, Ruby Quiz wrote: > > > The three rules of Ruby Quiz: > > > > 1. Please do not post any solutions or spoiler discussion > for this quiz until > > 48 hours have passed from the time on this message. > > > > 2. Support Ruby Quiz by submitting ideas as often as you can: > > > > http://www.rubyquiz.com/ > > > > 3. Enjoy! > > > > Suggestion: A [QUIZ] in the subject of emails about the > problem helps everyone > > on Ruby Talk follow the discussion. > > > > > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= > -=-=-=-=-=-=-=-=-= > > > > This week's Ruby Quiz is about text generation. That's > right, we're going to > > teach your computer to weave tall tales. > > > > At its most basic level, a solution might be: > > > > >> (1..30).map { (("a".."z").to_a + [" "] * 10)[rand(36)] }.join > > => "fb mcr hhluesjbhtf swm eehokmi" > > > > However, let's make our goal to get as close to English > looking sentences as > > possible. One way you might do this is using a technique > called Markov Chains. > > > > To use Markov Chains, you read some text document(s), > making note of which > > characters commonly follow which characters or which words > commonly follow other > > words (it works for either scale). Then, when generating > text, you just select > > a character or word to output, based on the characters or > words that came before > > it. > > > > The number of previous characters or words considered is > called the "order" and > > you can adjust that to try and find a natural feel. For > example, here is some > > generated text using a second order word chain derived from > the Sherlock Holmes > > novel "The Hound of the Baskervilles" by Arthur Conan Doyle: > > > > The stars shone cold and bright, while a crushing > weight of responsibility > > from my shoulders. Suddenly my thoughts with sadness. > Then on the lady's > > face. "What can I assist you?" > > > > If you need text's to prime your program with, I suggest > searching Project > > Gutenberg: > > > > http://www.gutenberg.org/ > > > > > >