dariusk / NaNoGenMo-2015

National Novel Generation Month, 2015 edition.
340 stars 21 forks source link

Co-authored Procedural Novel #83

Open dariusk opened 8 years ago

dariusk commented 8 years ago

Thought experiment: you and I are playing a game. I write ten opening sentences for a novel, and you pick the one you like best and let me know; that becomes the opener. Then I write ten second sentences for the novel. You pick what you like best and let me know. Et cetera.

Who wrote the book? I wrote literally every word, but you dictated nearly the entire form of the novel.

I plan to act as sentence-by-sentence editor for an algorithm (or set of algorithms) where I review something like 5,000 multiple choice questions and hand pick each sentence of the novel.

Right now I'm using an extremely naive function that just pulls random sentences from Gutenberg using gutencorpus. Here's ten sentences, derived from 10x10 sentences that the algorithm gave me:

She added hot baths, sitz baths, shower baths, and plunges. The tableau all waned at last with the pallidness aloft; and once more the Pequod and every soul on her decks were wrapped in a pall. As a brother, a landlord, a master, she considered how many people's happiness were in his guardianship! Jane met her with a smile of such sweet complacency, a glow of such happy expression, as sufficiently marked how well she was satisfied with the occurrences of the evening. And it is much to be deplored that the place to which you devote so considerable a portion of the whole term of your natural life, should be so sadly destitute of anything approaching to a cosy inhabitiveness, or adapted to breed a comfortable localness of feeling, such as pertains to a bed, a hammock, a hearse, a sentry box, a pulpit, a coach, or any other of those small and snug contrivances in which men temporarily isolate themselves. No: because the mails are very irregular between here and New Guinea. If we had not used it, that blessed child would have! They fence with their long lower jaws, sometimes locking them together, and so striving for the supremacy like elks that warringly interweave their antlers. But a mob without any man at the head of it is beneath pitifulness. "For eight-and-forty hours let me charter your ship--I will gladly pay for it, and roundly pay for it--if there be no other way--for eight-and-forty hours only--only that--you must, oh, you must, and you SHALL do this thing.

I picked the order of the sentences and I do think it hangs together with more coherence than quick experiment like this usually does. My plan is to use doc2vec or similar, with maybe a few other tricks, and have the algorithm take into account at least the very last sentence I gave it to give me a more coherent set of options (with this pure random sentence thing, usually only 1 or 2 out of 10 options makes any sense at all).

ikarth commented 8 years ago

Very OuLiPo-ish.

dariusk commented 8 years ago

So I've moved away from picking random sentences and instead am using doc2vec. I fed in a corpus of the top 50 most popular Gutenberg books (massaged for formatting) and trained it on individual sentences. About 44,000 sentences total. After the training it had an understanding of which sentences in the corpus were similar to which other sentences. So it knows that "PRIDE AND PREJUDICE" is similar to "HARPOONEERS AND SAILORS".

I use the above multiple-choice program but what I'm doing instead of random sentences is going through each line of Pride and Prejudice and asking it for the ten most similar lines in the corpus. If I were to carelessly pick the most similar line each time, here's what the first 20 lines of the novel would look like:

HARPOONEERS AND SAILORS. By Charlotte Perkins Gilman Chapter 39 It is a witchery of social czarship which there is no withstanding. Although there is little recorded of the youth of Machiavelli, the Florence of those days is so well known that the early environment of this representative citizen may be easily imagined. "Miss Eliza Bennet," said Miss Bingley, "despises cards." "I answered that I had not. "Yes, the widow told me all about it." Darcy made no answer. "Do you know him?" "I have no questions to ask him." This was satisfactory. " When we was at dinner, didn't you see a n*****r man go in there with some vittles?" "What is it?" said his comrade. "Paddles were dropped, and oars came loudly into play." "Is he quiet?" "Boy, that's a lie." "What ain't a dream?" "Oh, Lizzy! it cannot be." "Complied with! I am only ashamed of his asking so little."

Now here's the "edited" version I came up with for those first 20 lines:

HARPOONEERS AND SAILORS. By Charlotte Perkins Gilman Chapter 1 It is a witchery of social czarship which there is no withstanding. To this discovery succeeded some others equally mortifying. "Do let me ask my partner to introduce you." When he had finished, Mr. Jones said: "But have you told me all?" She smiled, but made no answer. "What is it?" cried Fred. " I want it." Her ladyship was highly incensed. "You must learn some of my philosophy." "What is it?" [They fall into each other's arms.] "My God!" he cried." There will be a large accumulation of property. "It's a bonny thing," said he." "Oh, it is childish." "I assure you that I am in your hands."

Spicy!

dariusk commented 8 years ago

New algorithm: instead of going line-by-line through Pride and Prejudice, we branch through all the books we have available. Like this:

Here's the result of one run:

HARPOONEERS AND SAILORS. THE SCENES OF THE PLAY BOOK I. CHAPTER V. [Cuts a flower.] Algernon. I shall die. Yet mine shall not be the submission of abject slavery. Both, if necessary, I presume. What is your income? Jack. [Moving to her and shaking hands.] What freedom? [The music stops and Algernon enters cheerily.] Algernon. Trouble is brewing. "It's a lie." "I reckon he's a goner." "Don't be grieved!" He was silent.

dariusk commented 8 years ago

Here's another run of the same jumping-around algorithm. It's definitely less coherent but it does this neat thing where it sort of jumps between styles.

THE ADVENTURE OF THE BERYL CORONET When one is in town one amuses oneself. That is just the way with some people. I don't remember anything about it. Chasuble. Miss Prism. Never had his wit been directed in a manner so little agreeable to her. "Do you love rats?" "Oh, I don't know." " But we got to let that go." "Why, I can't do that, it ain't in the book." "Well, that's so." "Here's the book." "Less see it." He unrolled it. His face flushed and darkened. His lantern swung from his tightly clenched hand. He saw the vast, involved wrinkles of the slightly projecting head beyond. A mist covered both that and the surrounding mountains. Beaded dewdrops stood upon the leaves and grasses.

I'm suspecting this is TOO random -- I may have it do mostly the "follow a single book and create analogies from that" thing for a while and then every now and then have it skip. Just to keep things interestingl

dariusk commented 8 years ago

Here is an example where it mostly sticks to a bunch of passages in a row but then branches out every now and then to a different passage:

HARPOONEERS AND SAILORS. By Charlotte Perkins Gilman It is very strange. It was the first of a long series of such outrages, of which I was doomed to be a witness and a participant. It made me shiver. It was to me the starting-point of a new existence. It was a terrific, most pitiable, and maddening sight. I could with pleasure have destroyed the cottage and its inhabitants and have glutted myself with their shrieks and misery. I passed the night wretchedly. I cannot tell, can only hint, the things that darted through me then. Oh! I am a Liberal Unionist. And so, through all the thick mists of the dim doubts in my mind, divine intuitions now and then shoot, enkindling my fog with a heavenly ray. I have often wished myself a beast. It was not joy only that possessed me; I felt my flesh tingle with excess of sensitiveness, and my pulse beat rapidly. Then I bounced for the top in a hurry, for I was nearly busting. "My first glance is always at a woman's sleeve." "What is it like?" "Oh, it ain't anything." "Better and better, man."

dariusk commented 8 years ago

And another one with sometimes-random branching, this time with semi-random newlines (there's always a new line on new dialogue starting with " or ' and then occasionally a non-dialogue sentence will end up on a new line too).

HARPOONEERS AND SAILORS. By Charlotte Perkins Gilman "It must be confessed, however, that the case looks exceedingly grave against the young man, and it is very possible that he is indeed the culprit." ''Tis so,' said the Duchess: 'and the moral of that is--"Oh, 'tis love, 'tis love, that makes the world go round!"' "Ah! that is suggestive." And so it was.--Most miserable! "Oh, yes!--that, that is the worst of all." I replied in the affirmative. He asked me all sorts of questions, too, and pretended to be very loving and kind. It is getting to be a great effort for me to think straight. "You see it, Watson?" he yelled." "You numskull, didn't you see me count 'm?" But I never said so. Tom Sawyer said I was a numskull. I was very glad to hear him say that; it made me feel much more easier than what I was feeling before. The boy stammered, gasped, and got it out: " By and by one showed." I took out my revolver and laid it on the corner of the table. Then the door of the bedroom opened and I felt dreadfully.

dariusk commented 8 years ago

Here's a complete book, though it's not quite 50,000 words (it's more like 48k).

http://tinysubversions.com/nanogenmo/2015/harpooneers/

NOT my official entry for this since it doesn't meet the length requirement.

dariusk commented 8 years ago

Err, updated with the source code. I'm sorry: https://github.com/dariusk/harpooneers

dariusk commented 8 years ago

@hugovk I was considering marking this as complete since it comes awfully close and does include the source code... what do you think?

hugovk commented 8 years ago

If you include the source code (but not the corpora) in an appendix in the back of the final, printed volume it's almost 52k.

Congratulations, have a Completed label!