Thursday, April 14, 2011

Vintage 1970s haiku generator by my granddad

Ross Ainsworth Dierdorff, 1922-2011

Back in January, I received a bundle of my grandfather's papers, following his passing, from my uncle. The papers detailed a simple algorithm my grandfather written to randomly generate haikus. My uncle, who also works in the field of math and computer science, had wanted me to take the notes, the BASIC implementation and the hand written word lists and see if I could recreate the program.

In this day and age, writing a haiku generator would not be much of a challenge. It would likely be an extra credit assignment in an Introductory 101 Java class. I felt that porting from BASIC to a modern day language would be a bit backwards, when I could just write a haiku generator in a modern language using modern paradigms. However, if I were to do that, then all I would have is a haiku generator with no relation to the one I was trying to memorialize. The point would be missed, I realized, the more that I thought about it.

Then I realized that the point isn't to recreate a haiku generator, which is something today's technically inclined youth could teach themselves to do thanks to the abundance of freely available programming environments and introductions to programming and mathematics. The point is to put the original haiku generator on display, because what makes it better than a cheesy Javascript implementation* is that back in the 1970s, people like my granddad were programming computers to do things that were cool. Something like a computer program that generated haikus in the 1970s was not abstract mathematical nonsense. It was something real. You could show it off to your friends, enjoy the motivating feeling of tangible success and most importantly, have created something cool that breaks out of the occasionally dry realm of mathematics and science.

Using computer programming skills to create cool things is the motivating factor today for many people in computer science, especially those who are younger. Just watch The Social Network, for example. Everyone in this field wants to create the next cool thing, or at least something they can show off to their friends that doesn't just seem completely uninteresting and dry. I have always seen computer science as a more creative branch of technical skill; it has always had much more of a counterculture streak without the stuffiness of the hard math and science world. People (at least those that I know) don't get into computer science because they enjoy number crunching or rigorously controlled experimentation, they get into it because it's fun and if you work hard you can create fun things.

Enough with the romanticizing, however. To start out, I have uploaded transcribed versions of the interactions with the terminal, in full. This includes a full terminal based code input and a bunch of outputs, all formatted precisely the way they were in the print outs.

Transcript 1 is the main file and contains code input along with output, plus some vintage-y terminal stuff for those who like that sort of thing.

Note that the code in transcript 1 contains ""; these arrows are representations of backspaces. The terminal printouts used these to demonstrate backspacing from a mistake and I kept them intact for integrity. Each "" is equal to one character backspaced.

Also take note of how even on a dedicated machine, each run takes about 260ms according to the transcripts. That may not seem like much; to the user at the time it was still pretty much instantaneous. However, in my fixed up version that runs in JBasic, below, I get results in less the 5ms and I am on my home laptop which is running a BASIC emulator inside of Java on a multitasking operating system.

The output of each run consists of a list of word types (NOUN, VERB, ADJ, ADV and MISC) followed by a two column list of numbers, that contains as many rows as the word type list. To parse the output, you take the nth row from the word type list and the nth row from the number list. The leftmost column on the number list is the number of syllables the word has, the rightmost column is the position in the word list table (for that stated number of syllables) and the word type is the table to look up the word in. For example, if you find that row one of the word type table is NOUN and that the left column of row one of the number list is "1" and the right column is "23", then you look in the noun table under the first column for row 23. This is the 23rd listed word for one syllable nouns. The word list is here, however I did not receive all of the words and so the list is visibly incomplete. If they turn up at some point, I will update this list.

For those who would like to try this program, I fixed it up with minimal adjustment so that it runs in JBasic. The adjustments made were only to make the application run properly, as not all flavors of BASIC are exactly alike and certain idiosyncrasies needed to be handled. JBasic is a free and open source BASIC interpreter written in Java, so it runs cross platform.

In order to run the haiku generator, first download JBasic. Then, download my JBasic ready version of the haiku generator. Run JBasic by opening a terminal window and typing java -jar <path to file>/jbasic.jar. Copy and paste the JBasic ready code into the terminal window (which should now be sitting at a BASIC> prompt, as JBasic is running) and click enter. Type run hma111 and the program should execute and output something similar to the above transcripts.

The haiku generator is a great example of vintage computer science and in my opinion, it timelessly represents the creative spirit of computer scientists in general.

Known bugs

  • "Licentious" is listed as a two syllable adjective, but it is three syllables. I have kept this intact for posterity.
  • Sentences are not checked for malformation in the BASIC code; a sentence or word string generated, while likely nonsensical, also has the potential to be unparsable English.

Notable output of the Javascript version

icon octopus evermore sallies chalice daily dupe occult
This is a particularly Lovecraftian haiku.
craven niche azure dregs torrid chrysalis smirk yield yield yield betcha
Problems arise when the only one syllable miscellaneous word I can find is "yield".
chic infidel ghoul chrysalis splendidly snare clairvoyant qualm arch
"Chic Infidel Ghoul" would probably last a season on ABC before fizzling.

*I have in fact created a Javascript version of the haiku generator, due to the high calibre of the word lists which I don't think should go to waste. There is one small change; although many of the haikus are still nonsensical, I do not believe that adjective/adverb use was controlled in the BASIC version. In my version, I made it so that nouns will always follow adjectives and verbs will always follow adverbs. The results will still be nonsensical, but they have less of a chance of being malformed word strings.

**I am claiming copyright in my name, Samuel Horwitz, and my grandfather's name, Ross A. Dierdorff on the inputted original code. As copyright holder, I release it under the MIT License. The fixed up code has the boilerplate legal in it but the original code from the transcript I did not want to modify as I wanted the transcript's integrity to remain intact.

6 comments:

  1. wow so cool what an amazing grandfather/grandson connection

    ReplyDelete
  2. Samuel, thank you for doing taking this on! How wonderful that you are carrying on Papa's creative work. He would be so proud and happy about this, I'm sure. You've even made it so that I can understand some of what you said! That's a feat in itself since I'm probably the most "untechy" relative you have.
    Love, Aunt Anne
    P.S. What is "select profile" about anyway? I'm just guessing on this since I have gmail. ??

    ReplyDelete
  3. P.P.S. Guessed wrong, I suppose, b/c, interestingly, our China Tour blog came up. Goodness knows why... (When we were in China, it was blocked, so son Ross put it up after our return.) Love, Aunt Anne

    ReplyDelete
  4. Contact 1-855-637-4055 for any specialist clairvoyant readings. I'd enjoy take time to help tell you information about OUR most innovative free psychic readings site. I has become previously operating genuinely really hard, thank an individual for permitting me to mention the actual with you.

    ReplyDelete