Generative Creativity Lecture 5:
Jokes


Introduction

Wide range of joke genres


Punning riddles

How are jokes like this constructed?


STANDUP riddles and puns

Run 'STANDUP/STANDUP Simple.bat'


Simplified riddling

In the simplest riddles the answer is a compound word which combines two other words, such that one of the words is a pseudonym for the object specified in the question, and the other satisfies the description, e.g.,

Here `tail' satisfies the description `wags' and `plane' is a type of flat surface.


In Java

Given knowledge of the substitution procedures involved, it is possible to write a program which generates possible combinations from a suitably-structured dictionary.

WhatDoYouCall.java provides a very simple illustration of this approach.

Ritchie's STANDUP system is a more advanced application.


WhatDoYouCall applet

   import javax.swing.*;
   import java.awt.event.*;
   import java.awt.*;


   class JokePanel extends JPanel {
      String string;

      public void paintComponent(Graphics g) {
         super.paintComponent(g);
         if (string != null) g.drawString(string, 10, 20);
      }
   }


   public class WhatDoYouCall extends JApplet implements MouseListener {
      String answer = null;
      int index = 0;
      JokePanel jokePanel = new JokePanel();

      String map[][] = {
         {"tail", "pursuer", "wags"},
            {"plane", "flat surface", "flies"},
            {"motor", "power source", "vibrates"},
            {"bike", "cycle", "has pedals"},
            {"car", "vehicle", "has four doors"},
            {"park", "nature reserve", "is open to the public"},
            {"ice", "glacier", "freezes"},
            {"box", "case", "you can keep things in"}
      };

      public void init() {
         this.addMouseListener(this);
         jokePanel.setBackground(Color.white);
         getContentPane().add(jokePanel);
      }

      public void mousePressed(MouseEvent event) {
         if (answer != null) {
            jokePanel.string = "Answer: " + answer;
            answer = null;
            index += 2;
            if (index >= map.length) index = (index+1) % map.length; }
         else {
            int i = index, j = i-1;
            String thing = map[i][1], desc = null;
            if (i % 2 == 0) j = i+1;
            desc = map[j][2];
            jokePanel.string = "Question: what do you call a " + thing + " that " + desc + "?";
            answer = map[Math.min(i,j)][0] + map[Math.max(i,j)][0]; }
         repaint();
      }

      public void mouseReleased(MouseEvent event) { }
      public void mouseClicked(MouseEvent event) { }
      public void mouseEntered(MouseEvent event) { }
      public void mouseExited(MouseEvent event) { }

  }

Applet in action


More complex riddles

Question: What's the difference between leaves and a car?

Answer: one you brush and rake and the other you rush and brake

Relationships exploited

The structural connections involved in the more complex riddles generated by STANDUP are made using homophones (words which sound alike), synonyms (different words which mean the same thing), descriptions, attributes and class relations.

For example


Riddle template

Question: What do you call a X=murderer with Y=fibre?

Answer: a ATTRIBUTE(SYNONYM(Y),X) SYNONYM(X)
Filling in the template produces: A cereal killer

A similar approach produces


Summary


Exercises


Reading

The WhatDoYouCall applet is inspired by Kim Binstead and Graeme Ritchie's work on JAPE-1: Binstead and Ritchie 1994, 1997

A draft report on the STANDUP system (successor of JAPE-1 and JAPE-2) is at here. This is due to appear in Applied Artificial Intelligence.

See also Graeme Ritchie's recent book: `The Linguistic Analysis of Jokes'

Try Ritchie's by-hand joke-generation task: instructions here, worksheet here


Page created on: Wed Jan 14 11:16:40 GMT 2009
Feedback to Chris Thornton