This was not, obviously, silly enough for my tastes, so ...

Michael Walker trained a Markov chain with the King James Bible and Structure and Interpretation of Computer Programs , a classic computer science textbook.

Half an hour on CPAN and in vim, and then some discreet dumpster-diving in the nether reaches of the internet, brought me three things:

A dodgy copy of the complete works of H. P. Lovecraft

The text of the King James Version of the Bible

And the first code I've written in, oh, close to two years ( please go easy on me )

Here it is:

#!/usr/bin/perl #=========================================================================== # # FILE: lovebible.pl # # USAGE: ./lovebible.pl # # VERSION: 1.0 # CREATED: 05/12/2013 20:08:15 GMT # REVISION: --- #=========================================================================== use strict; use warnings; use Algorithm::MarkovChain; use Path::Class; use autodie; # die if problem reading or writing a file my @inputs = qw(king_james_bible.txt lovecraft_complete.txt); my $dir = dir("."); my $f = ""; my @symbols = (); foreach $f (@inputs) { my $file = $dir->file($f); my $lcounter = 0; my $wcounter = 0; my $file_handle = $file->openr(); while( my $line = $file_handle->getline() ) { chomp ($line); my @words = split(' ', $line); push(@symbols, @words); $lcounter++; $wcounter += scalar(@words); } print "$lcounter lines, $wcounter words read from $f

"; } my $chain = Algorithm::MarkovChain::->new(); $chain->seed(symbols => \@symbols, longest => 6); print "About to spew ...

"; print "---



"; foreach (1 .. 20) { my @newness = $chain->spew(length => 40, complete => [ qw( the ) ]); print join (" ", @newness), ".



"; }

krina:markov charlie$ ./lovebible.pl 2> /dev/null 99820 lines, 821134 words read from king_james_bible.txt 16536 lines, 775603 words read from lovecraft_complete.txt About to spew ... --- the backwoods folk -had glimpsed the battered mantel, rickety furniture, and ragged draperies. It spread over it a robber, a shedder of blood, when I listened with mad intentness. At last you know!At last to come to see me. Now Absalom. the absence of any real link with that of 598 Angell Street was as the old castle by the shallow crystal stream I saw unwonted ripples tipped with yellow light, as if those depths of their rhythm. The training saved them. the bed, and make thee borders of gold with studs of silver. 1:12 While the case histories, to expect. As mental atmosphere. His eyes were pits of a hundred and fifty shekels, 30:24 And he laughed mockingly at the village summoning. the commandment of the room; then this. If this thing. 25:1 If he had no way to turn either to the coyote - or to something was wrong. Marsh and Marceline represents. I am strong. 26:16 I also in me. 14:2. the ghouls, whose utter strangeness and their backsliding, I will love him, and have redeemed them, yet thou never gavest me a people: 8:11 And I said unto them, and I believe that the king doth behold the upright. 33:2 Thus. the gleaming sand, bobbing lanterns. The Philistines be upon thee, and because the famine in the heart proceed evil for Israel, with hesitancy, and which I had known it, to himself, he said, How shall depart from his house. 7:2 That. the results we learned that no harm him, and rent it. 7:22 My face again no not to inform me, even all the heads of the unutterable consequences. It could tell, it thunders. The thing came out of Egypt. Who knoweth. the grass-grown line on the glassy, phantom bones. 50:18 Therefore the children of Israel dedicated the sea, diverse and I hung an air of the war, to rest in my brother for nought, and the counsellor, and the cunning workman, and. the great hill that put bitter weeping; Rahel weeping for Tammuz. 8:15 As it fastened his body to the dead youth who would "go the king lifted up his Son of Professor George Saintsbury - "the criminal is securely strapped to.

Yes, it's a Markov chain generator, seeded with the King James Bible and the complete works of H. P. Lovecraft. Sample output:

As you can see, the output is pretty crude. Obviously this was a half-hour hack, not a properly finished product; but I think it shows promise — His eyes were pits of a hundred and fifty shekels — and a definite feel of familiarity — It spread over it a robber, a shedder of blood, when I listened with mad intentness.

Stuff to do: fine-tune the parameters of the Markov chain output, pick different seed words, possibly filter out chapter headers, titles, and verse numbers, possibly scan the output for sentence-shaped lexical chunks and top and tail them (capitalize and terminate properly).

I wonder: if I run it for long enough, will it emit a fully-formed draft of the Necronomicon?