NaNoGenMo / 2020

National Novel Generation Month, 2020 edition.
76 stars 0 forks source link

"Cheaply the satisfied vampyre was trying the neighbourhood" -- Nano-NaNoGenMo entry #28

Open kappa opened 3 years ago

kappa commented 3 years ago

Pretty straightforward: let's use some heuristics to fish a text for verbs, nouns, adjectives and adverbs and then generate random sentences using patterns.

And do it in <=256 characters because #NNNGM and I have not played Perl golf for many years.

kappa commented 3 years ago

$ perl -0pe'$_=lc;y/a-z.,/ /c;$c="[^aeiuo ]";@v=/ (was \S\S+(?<!th)ing)\b/g;@a=/ (?:be|most) ($c\w{4,})/g;@A=/(\S+ly)/g;@n=/ (?:the|a) ($c\S\w+)(?<!s)[.,]/g;@R=(the,a);@P=(RnAvRan,ARanvRn);$\.=(join$",map$$_[rand@$_],$P[$$%2]=~/./g).".\n"while--$$}{' pg14833.txt

Uses Varney the Vampyre but will work with any sufficiently large English text.

kappa commented 3 years ago

An excerpt:

hastily the rural letter was perusing a house. a belfry melancholy was raging a supposed visit. exactly a happy mile was talking the child. the picture certainly was making the deliberate place. accurately a something spot was travelling the gate. a hedge certainly was taking the raised chair. strangely the quite consideration was going a mangled. a populace only was dawning the certainly change. goodly a found place was writing a hall. the breast rightly was going a sufficiently low. acutely the pleased window was willing the whisper. the book likely was getting a sucked wine. lately a possible conversation was waiting a staircase. a clear generally was standing the careful pike. frequently a supposed bed was spreading the smile. the butcher greatly was hurting the released place. wonderfully a disappointed rush was going a room. a least specifically was taking the furiously family. promptly the connected matter was rising the death. the figure nearly was labouring a fairly lawyer.

kappa commented 3 years ago

The length of the generated text is not constant, sometimes it will be shorter than 50k words -- depends on the current state of the OS as it uses PID as a "random big number" and PIDs are not always big enough.

There are also multiple ways to trade characters for quality. I stopped at exactly 256 characters.

hugovk commented 3 years ago

If you post a 50k+ version somewhere you can have a completed label!

kappa commented 3 years ago

Done! https://gist.github.com/kappa/0556b230afe95ecec1f21bd4a6b38046

pjfpotter commented 3 years ago

That was fast