Telling jokes – knock, knock

Our next section comes at the request of my grandson, William, who just adores knock-knock jokes. William is seven, so he is just the right age for this. As you probably know, knock-knock jokes are a pun-based joke that always takes the same form. (person 1) Knock, knock (person 2) Who’s there? (person 1) Wooden (person 2) Wooden Who? (person 1) Wooden you like to know!

So the dialog is very simple. Several parts of it are automatic, such as the first two lines – Knock, knock and Who’s there?. We can create a generic knock-knock joke in the following form:

  1. Knock, knock.
  2. Who’s there?
  3. <word 1>
  4. <word 1> who?
  5. <punchline phrase>

In defining our joke, you can see we just have two variable elements – the word in ...

Get Artificial Intelligence for Robotics now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.