Why I did it
Some time ago, I found a website which lets you play Madlibs by filling out a form from a set of hand-made templates, and thought, why couldn't a computer make these templates? It's just classifying words, and how hard could that be? And so, more recently, I decided to do research on what is involved in writing a Madlib, as well as software libraries that could automate this process.
What is it
Just like any other game of Madlibs, you get asked to supply words of a given part of speech, and your answers get put into a text with usually humorous results. If you wanted to go into the game blind, meaning that you couldn't see where your answers were going, then you would typically need some other person to make and manage the game for you. In my program, the computer acts as this 2nd person in picking which words to give you and accepting your input, and can act in a fairly smart way. Better yet, since it is computed on the spot, you can give it any text whatsoever and it will spit out a randomized game for you.
Now, I am not the best at making GUI's, so you can only play it on the terminal for now. However, the processing and input components are pretty separate, so I'm sure it won't be too difficult to write another front end to this.
With what
The first library I stumbled on was NLTK, the Natural Language Tool Kit, but I quickly found it too difficult work with, primarily because it was meant to be used to build more functional tools and required you to train certain models yourself to get certain functionalities. This would've taken a lot of effort, and I am lazy, so I looked for alternatives.
The next library I found was SpaCy, which advertised itself as being heavy duty and production ready. This came with pre-trained models and was much more convenient overall, so this was what I decided to use for my project.
How
Armed with the research I did on how to write Madlibs, I set out to replicate how it was done in python. Some things I focused on were classifying words based on Pen-Treebank tags and displaying their respective descriptions, processing text by sentence and choosing figuring out an equation to determine how many to blank out based on sentence length, randomizing variables so that you get a different layout every time, making a basic command line interface, and finally doing some post-processing to correct some issues with grammar.
Log in or sign up for Devpost to join the conversation.