using a Markov Chain, because this question itself as input text for example

7

1

Create a Markov Chain generator, which generates (and outputs) an Order 4 text chain. It must be able to support all plain text formatting used on this question, so be sure to check for punctuation (parentheses count for example, but HTML doesn't need to be accounted for fortunately)! You could even use this question itself as input if you're so inclined. There must be a defined input variable (or something analogous to such, I am aware certain popular esoteric languages do not really have variables per se.)

Your generator also should start sentences with a capital letter, and end with ".", "!", or "?", according to how often those respective characters appear in the input text.

You must also include a way to change the amount of text which should be output, so the only two things that are really configurable are the amount to output and the input string. It should stick with an Order 4 chain, because those happen to be funniest when it all comes down to it really.

Oh and, if your generators happen to create something particularly funny, please feel free to include it in your post for the lulz.

The title of this question was generated using a Markov Chain.

Cyclone

Posted 2011-07-06T18:14:30.697

Reputation: 179

1Can you explain more and give sample I/O? I don't really understand the challenge. – Peter Olson – 2011-07-06T18:40:45.993

1

@Peter Take a look at http://en.wikipedia.org/wiki/Markov_chain#Markov_text_generators

– Cyclone – 2011-07-06T19:08:58.543

4

Welcome to CodeGolf.SE! You might want to review the FAQ section on questions because your post is a bit underspecified and does not seem to defined a task for which there is an objective winning criterion. Possibly you intend this to be [tag:code-golf]? If so it should be tagged as such because we support other categories of puzzles and tasks.

– dmckee --- ex-moderator kitten – 2011-07-06T19:11:43.397

Answers

3

Perl, 108 chars

What, no answers? Here's a quick Perl solution:

$/=$,;$_=<>;push@$1,$2while/(?=(....)(.))/sg;print+($m)=/(....)/s;print while($m.=($_=$$m[rand@$m]))=~s/.//s

And this is what I got the first time I fed the question text through it:

Create a defined. There must also inclined. There must be sure to be according a Markov Chain.

(The average output length should approximately match the input length, so such a short output is quite untypical. On the other hand, the output length is roughly exponentially distributed, so both very short and very long outputs are quite possible.)

Ilmari Karonen

Posted 2011-07-06T18:14:30.697

Reputation: 19 513