Saturday, March 5, 2016

Initial Experiments with Automatically Generating Ironic Statements

The other day, I came across a simple "ironic" phrase of the form below:

As subtle as a sledgehammer

I saw this example in Tony Veale's "Detecting and Generating Ironic Comparisons: An Application of Creative Information Retrieval".
Seeing this made me wonder if interesting examples of this type could be automatically generated. Veale mentions this in his paper, and he is looking at generating more sophisticated types of ironic statements. I believe these are sometimes referred to as ironic similes.

I put together a starter node.js project to try to do this. A sample of these are automatically tweeted on the twitter account @theironycat. A live feed of these tweets is shown on the right.

A few of the initial ones that seemed kind of ok are shown below. There is a lot of room for improvement.

Technical details are further below.

Some Technical Details

The basic idea is as follows:

  • pick a random noun N
  • find adjectives that seem to be used to define the noun (and its synonyms)
  • find antonyms of those adjectives, and pick a random one A
  • use the phrase "As A as a N"
Picking a Random Noun

The list of nouns is taken from the Princeton's WordNet database. The wordnet-sqlite node.js package is used to simplify working with the WordNet dictionary, whereby you can run basic sql commands to grab all of the adjectives and nouns. wordnet-magic is used to get detailed information from the dictionary for synonyms, definitions, and antonyms.

Getting Adjectives Describing the Noun and its Synonyms

This is an important step, and is where I think the most improvement can be made next. For now, I first get all of the words in all of the definitions of the word and its synonyms, and then find those words that are adjectives (using the isAdjective function that wordnet-magic has).

Note: some of the words that WordNet considers "adjectives" are suspect (imo). I still need to filter out some of those.

Finding Antonyms of the Adjectives

This is very simple, as I can use the getAntonyms method for each adjective that wordnet-magic provides.

I also tried to use the moby thesaurus to get more synonyms for these antonyms, but while there was a wider range of words, the results seemed to be even less interesting (and often the synonyms for adjectives could be nouns).

Some Notes so Far

Sometimes the generated phrases are pretty close, and even though others so far might not be much good yet, it frequently happens that the strange combination of diverse concepts can be humorous. I think the phrases can create neural connections or something that "tickles" your brain. The phrases can be more Fellini-esque than "ironic".

Sometimes the phrase is more of an accurate statement rather than ironic - for example, "as small as an urn". This just highlights the extra work I need to do on the adjective part.

So, next I'll see about making some improvements on the choice of the adjectives.

Comments welcome.