[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/
>

"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!

<laughs>

I should actually mention this idea was not mine. Eric Hodel gave it to me. I just wrote it up. Thanks Eric!

Do you have any preferernces for the command line parameters?

Na. Just document what you use please, so I can figure out how to run it. :slight_smile:

James Edward Gray II

···

On Apr 7, 2006, at 9:21 AM, Kroeger, Simon (ext) wrote:

:slight_smile: So how about running the solutions over the solutions, and seeing if
the result will execute? :slight_smile:

···

On Apr 7, 2006, at 9:21 AM, Kroeger, Simon (ext) wrote:

"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!

<laughs>

I should actually mention this idea was not mine. Eric Hodel gave it
to me. I just wrote it up. Thanks Eric!

"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!

<laughs>

I should actually mention this idea was not mine. Eric Hodel gave it to me. I just wrote it up. Thanks Eric!

The real trick is being space efficient. Markov text generation is a very simple algorithm, but being more english-like requires a larger corpus of input text.

The best-reading solutions will use the largest input text corpus stored the smallest space.

···

On Apr 7, 2006, at 7:52 AM, James Edward Gray II wrote:

On Apr 7, 2006, at 9:21 AM, Kroeger, Simon (ext) wrote:

Do you have any preferernces for the command line parameters?

Na. Just document what you use please, so I can figure out how to run it. :slight_smile:

--
Eric Hodel - drbrain@segment7.net - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com

You are welcome to try it and find out... :wink:

James Edward Gray II

···

On Apr 7, 2006, at 11:45 AM, benjohn@fysh.org wrote:

On Apr 7, 2006, at 9:21 AM, Kroeger, Simon (ext) wrote:

"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!

<laughs>

I should actually mention this idea was not mine. Eric Hodel gave it
to me. I just wrote it up. Thanks Eric!

:slight_smile: So how about running the solutions over the solutions, and seeing if
the result will execute? :slight_smile:

Eric Hodel schrieb:

I should actually mention this idea was not mine. Eric Hodel gave it
to me. I just wrote it up. Thanks Eric!

The real trick is being space efficient. Markov text generation is a
very simple algorithm, but being more english-like requires a larger
corpus of input text.

The best-reading solutions will use the largest input text corpus stored
the smallest space.

If the text corpus is very small i tend to get complete sentences from
the original - so very english-like.
But in the more general case i guess you are right.

cheers

Simon