Anyone who regularly visits Hacker News has seen the "Show HN: {proper noun} — a[n] {adjective} {noun} written in {trendy language}” headlines. Inspired by a HN comment surmising that all HN project descriptions are really written by Markov chains, I decided to write a Twitter bot that generates “Show HN”-style headlines.
Since this bot generates headlines (rather than the longer project descriptions the original author described), I decided that a Madlib-style approach would be appropriate. It follows the following pattern:
Show HN: {proper noun} — a[n] [{adverb}] {adjective} {noun}, [{adverb}] {verb} in {language}
The goal here was to create a new “word” to describe the project:
- Word length picked at random
- Random characters are selected; the random character picker biases towards consonants or vowels based on the previous character
- Capitalize the first letter, as well as other characters at random for CamelCasing
- Occasionally add a trendy suffix like .ly, Box, etc.
Uses WordNet to get random characters from the needed part of speech, using indefinite_article to add the article before the adverb or adjective
Right now, it just picks from a pre-determined list. I tried to use WordNet to get synonyms (or words from the same domain as "written"), but I couldn't figure out how to get results that made any semblance of sense.
Picks a language at random from the included langs.txt. The languages were scraped (see the included prog_languages script) from the Wikipedia listings for serious and esoteric programming languages.
When called with the "post" command-line argument, the generated headline will be posted to Twitter. This requires Twitter API access and user authorization.
Copyright 2015 Chris Snyder, released under the MIT license.