NaNoGenMo / 2022

National Novel Generation Month, 2022 edition.
51 stars 0 forks source link

#NNNGM: Deuxportrait #39

Open nmifsud opened 1 year ago

nmifsud commented 1 year ago

256-character program using the complete works of Mark Twain and Winston Churchill:

import nltk,random
t=[s for s in nltk.sent_tokenize(open('pg3200.txt').read()+open('pg5400.txt').read())if(s.startswith(('My','I am','I do','I can','I have','I would'))&(len(s)<150))]
random.shuffle(t)
print(' '.join((' '.join(t).replace('"','')).split()))

Here's the output (51,967 words). Sample:

I have seen it stated in print that as a boy I had been guilty of stealing peaches, apples, and watermelons. I have made a thousand vows. I am afraid you deserve your loss. I do not know why they have done this, but I think it is from dishonest motives. My father has so many cares, and he tries so hard to do right as he sees it.

This was an attempt to create a novel in the style of Edouard Levé's Autoportrait, which is made up of sentences like these:

The higher the floor number, the better I feel. Sometimes I realize that what I’m in the middle of saying is boring, so I just stop talking. I used to think I worked better at night than in daytime until one day I bought black curtains. I use the shell of the first mussel to spoon out the rest. I can do without TV.

Of course you could get closer to this by using a larger set of more constrained sentence forms (and drawing on more inputs to compensate for how few sentences each would provide). But this nano-entry was enough to scratch my itch!