
Generative Creativity Lecture 5:
Jokes
Introduction
Wide range of joke genres
- What do you call a X that Ys?
- shaddy dog stories,
- englishman/irishman/scotsman,
- how many Xs does it take to Y?,
- knock knock,
- word play,
- cultural humiliation (irish/kiwi/norwegian...)
Punning riddles
- Question: What do you call a chav in a box?
- Answer: init!
- Question: what do you call a chav in a filing cabinet?
- Answer: sorted
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.,
- Question: what do you call a flat surface that wags?
- Answer: a tailplane.
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
- murderer SYNONYM killer
- fibre ATTRIBUTE person
- person SUPERCLASS killer
- cereal HOMOPHONE serial
- serial ATTRIBUTE murderer
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
- Question: What to you call a strange market?
- Answer: a bizarre bazaar
Summary
- Jokes often involve specific structural characteristics.
- These can be used for generative purposes.
- Punning riddles are a simple case but even here it is difficult to
reliably generate riddles which are considered funny.
Exercises
- Work out a structural template which would generate `what do you
call a killer with fibre' from the answer `cereal killer'.
- One of the problems with the applet is that, as it stands, it cannot
cope with pseudonyms starting with a vowel. In these case the question
form should use `an' rather than `a'. Modify the code so that this
situation is recognized and the question modified appropriately.
- Extend the applet by adding entries to the 'map' for the compound
words `jailbird' and `braindrain'.
- Modify the applet so that it generates questions in a
random order.
- Modify the program so that it is capable of generating
questions featuring imaginary compound words, i.e., words
which make use of one or more pseudonyms.
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