Computer Joke Generator

Computer Joke Generator Photo Credit: Clipart.com

A computer program tells jokes, some of which are judged both original and funny.


Computer-generated comedy. I'm Bob Hirshon and this is Science Update.

Here’s a joke for you: “I like my coffee like I like my war: cold.” Not bad, for something written by a computer. The program was created by David Matthews and Sasa Petrovic at the University of Edinburgh’s School of Informatics.

We kind of wanted to see if we could formulate humor as a statistical model: basically come up with a mathematical model for generating jokes.

Petrovic says the jokes took the form of “I like my X like I like my Y,” then a one-word punchline. He and Matthews came up with a few basic rules for making this kind of joke work, and programmed them into the system.

Human judges found the computer’s one-liners funny 16 percent of the time. That’s about half the hit rate of jokes written by humans—and significantly better than control versions of the program, which created similar sentences without following the comedy rules. I’m Bob Hirshon for AAAS, the Science Society.

Making Sense of the Research

Humor is one of those human abilities that many people think will never be fully matched by computers. However, because humor is so complicated, it's an interesting challenge to write a computer program that can imitate it even in a very limited, modest way.

Surprisingly, this isn't the first attempt at computer comedy. Over the past decade and even earlier, computer programmers have designed programs that could either recognize jokes from non-jokes or tell some jokes of their own. Examples of topics covered include sarcasm, one-liners, two-liners, puns, and even “That's what she said” jokes.

However, these researchers have achieved something that other programmers haven't. To design other joke-generating systems, programmers used artificial-intelligence designs that “learned” by analyzing hundreds or thousands of jokes written by humans. As with many artificial intelligence programs, after processing enough “real” jokes, the computer learned how to imitate them.

In this case, the programmers wanted to write an actual mathematical formula for creating a joke, so that given the formula, a computer could, in a manner of speaking, start telling its own jokes without ever having heard a “real” one. The researchers focused on one particular joke construction: “I like my ____ like I like my ____: ____.” For example: "I like my men like I like my tea: hot and British,” (not a computer joke, by the way). 

The program, in complex mathematical terms, told the computer how to choose two nouns (like “men” and “tea” in the example) that shared some kind of common quality that could be described in an adjective (“hot” or “British”). According to the program, a funny joke requires two nouns that seem very unlike each other, but yet are often described by the two adjectives. If the nouns already seem alike, the joke is unsurprising; if they're rarely described by the two adjectives, the joke doesn't make much sense. 

They compared the jokes generated by the computer program to similar jokes written by humans, as well as jokes written by intentionally flawed versions of the program, which created similar sentences that didn't look for “funny” combinations. They found that the computer jokes were considered funny about half as often has human jokes, and more importantly, much more often than the non-joke program's sentences. 

Interestingly, when the programmers looked for the computer's most successful jokes online, they rarely found that humans had already come up with the same joke. The research may not lead to a new kind of comedy, but it may help computer scientists develop complex programs. The results are also consistent with what language experts have said about the basis of humor.

Now try and answer these questions:

  1. What kind of jokes did this computer program generate? Why was that kind of joke chosen?
  2. Since the computer's jokes weren't funny as often as humans', how did the researchers know their program still worked, to some extent?
  3. What's the difference between this experiment and prior experiments, in which artificial intelligence programs learned by studying examples of jokes?  
You may want to check out the August 16, 2013, Science Update Podcast to hear further information about this Science Update and the other programs for that week.This podcast's topics include: Scientists test a 3-D underwater microscope, how oxygen led to the rise of ocean carnivores, and why some fish are going back to school.

For another example of computer creativity, see the Science Update Computer Composer.

Computers tackle other everyday-life issues in Checkers Solved and Sports Rankings.

In Football and Artificial Intelligence, hear how scientists are using football footage to create computers that can analyze complex, action-packed visual scenes.

Going Further

For Educators

For another example of computer creativity, see the Science Update lesson Computer Composer.

Computers tackle other everyday-life issues in Checkers Solved and Sports Rankings.

In  Football and Artificial Intelligence, hear how scientists are using football footage to create computers that can analyze complex, action-packed visual scenes.

Related Resources

Ping-Pong Avalanches
6-12 | Audio
Thought-Controlled Robotics
6-12 | Audio
Yeast on Zoloft
6-12 | Audio

Did you find this resource helpful?

Science Update Details

Grades Themes Project 2061 Benchmarks