If on a winter's night a library cardholder
My National Novel Generation Month 2016 project
The script generates a new ~50,000-word, Markdown-formatted novel every time it is run. It is inspired by If on a winter's night a traveler by Italo Calvino.
I believe that there are 4.5 x 101366 possible novels that can be generated by this script. For comparison, there are an estimated 1082 atoms in the universe.
Project status: Complete
You, the protagonist, half-remember a book you read long ago and want to read again — but you can't remember the title. You visit each of the 216 library branches in New York City looking for it. At each library, you find a book that looks familiar and you read a page... Is this the book you've been trying to find?
- NYPL, BPL, and QPL branch names and addresses (compiled from NYC Open Data)
- Project GITenberg text files (main project page; data source)
- I didn't write a script that crawls the NYPL/BPL/QPL catalogs, and they don't have APIs (as far as I know). So the books the protagonist reads are random texts from Project Gutenberg that may not necessarily be found in the actual library branches. (Even though that would be waaay cooler.)
- NYPL: New York Public Library, serving Manhattan, the Bronx, and Staten Island. BPL: Brooklyn Public Library. QPL: Queens Public Library.
- Project Gutenberg texts are in the public domain. As with any historical collection, there are historical attitudes and language choices that aren't so hot today. Let's hope the protagonist chooses wisely...
How to run
- Download this repository. All data files necessary are included.
- Create a folder called 'drafts' inside the main repo folder.
- Run makebook.py from the command line or in IDLE.
- It should start printing library names to the screen. The script takes about 18 minutes total to run. (I built in very short pauses for politeness.)
- The script outputs a .md file inside the drafts folder. The filename is a timestamp. You should be able to open this file in a text editor or browser.
You arrive at 79-50 Bell Boulevard, Bayside, and find yourself on the steps of Windsor Park Library.
While browsing the stacks, something heavy suddenly falls onto your head. 'Ouch!' you shout. But no one is nearby. You rub your cranium and look at the red cloth-covered book that fell on you. 'Two Wyoming Girls and Their Homestead Claim: A Story for Girls,' you mutter. Perhaps this was a sign.
You flip to a random page and begin to read...
... Only think, we've been on this place nearly five years, and we've never yet raised a crop, because Mr. Horton's cattle, no matter where they may be ranging, always get up here just in time--the right time--to do the most damage. The other neighbors' cattle hardly ever stray into our fields, and when they do the neighbors are good about it. Think of the time when Mr. Rollins's herd got into the corn field and ate the corn rows down, one after another. Mr. Rollins came after them himself, and paid the damage, without a word of complaint. Besides, he said that it shouldn't happen again; and it didn't. When has Mr. Horton ever done a thing like that?" "]He's been kept busy other ways," father said, and his voice had none of the resentment that Jessie's expressed. ...
No, this isn't the book you had in mind, although it does intrigue you. You consider checking it out, but you don't have much time before the next branch closes. You go outside and point your feet toward the next branch on your list.
Creative Commons license CC-BY-NC