Programming a sense of humor

  • Thread starter kolleamm
  • Start date
  • #1
kolleamm
447
43
I've been developing an artificially intelligent software for a few years now. Its main goal is to have human like conversations with others. I've realized that humor is a very important part of conversation. After doing some research I may have found a definition for it -
"something that is unexpected and does not pose a threat".

Does anyone have any insight into this area of research?
Any tips or ideas of any sort to steer me in the right direction would be really great.

Thanks in advance
 

Answers and Replies

  • #3
Fervent Freyja
Gold Member
685
777
This reminds me of Russell's essay, "The Professors guide to laughter", in which he points out that humor cannot be placed into one particular formula for all people, since people and cultures can be so very different in how they function and what they find humorous can vary considerably. Although he states there are many formulas for humor, he saw that they have one thing in common, "Every formula treats what is living as if it were mechanical, and is therefore by his own rule itself a fitting object of laughter."
 
  • #4
kolleamm
447
43
Interesting. It's not a very easy topic indeed. Like you said, it varies by culture, so besides some things we all find universally funny, some other things people might disagree on. Randomness could also be a source of humor, that might be slightly easier to program. The problem is not an unsolvable one, it just requires some knowledge about the real world. The more knowledge you have the more jokes you will understand. The less knowledge you have the more likely you will mistake them for regular statements. Now with that said, what knowledge of the real world is actually needed is still something I have not yet pinpointed. I suppose it depends on what type of jokes are being made. Food jokes? Learn about food first, something along those lines.
 
  • #5
Fervent Freyja
Gold Member
685
777
Interesting. It's not a very easy topic indeed. Like you said, it varies by culture, so besides some things we all find universally funny, some other things people might disagree on. Randomness could also be a source of humor, that might be slightly easier to program. The problem is not an unsolvable one, it just requires some knowledge about the real world. The more knowledge you have the more jokes you will understand. The less knowledge you have the more likely you will mistake them for regular statements. Now with that said, what knowledge of the real world is actually needed is still something I have not yet pinpointed. I suppose it depends on what type of jokes are being made. Food jokes? Learn about food first, something along those lines.

Well, what makes something funny to a person depends upon their entire body of knowledge or the perception of the circumstances leading up to and surrounding that joke. There are many aspects that would have to be placed into context other than words or even body language. I find things funny and make jokes that few people seem to get. Some people seem to need to share their humor with other people, while some get pleasure out of joking with themselves. I don't find typical jokes very funny, but can sometimes sense that someone is joking. You are right, that is a large task, but probably could be done with universal aspects of human nature(gender jokes). Some animals also have a sense of humor.

One word can be considered a joke if placed into context of past, current, and future events surrounding a collective, not individualistic, body of knowledge. If you have a program running that can collect the common knowledge of a certain group, then having that program respond against that knowledge could be considered funny. Throwing people off can get their attention. For instance, I occasionally tease my 4 year old daughter about bits of knowledge or words, "Put on your goat" elicits her to respond, "Mamaaaaa, coat not goat!". I also make up something that I know is very contradictory to what she knows, which incites her to form good arguments against me. I figure if she can oppose me, then she will do so to anyone else. She's catching on now though and realizes that I'm joking. I will have to adapt my strategy here.
 
  • Like
Likes mister mishka
  • #6
Svein
Science Advisor
Insights Author
2,224
758
Robert A. Heinlein > Quotes > Quotable Quote
205.jpg

“I've found out why people laugh. They laugh because it hurts so much . . . because it's the only thing that'll make it stop hurting.”

Robert A. Heinlein, Stranger in a Strange Land
 
  • Like
Likes NorseMN and krater
  • #8
Fooality
196
42
It always hit me how apeish laughter is, a remnant of our ancient primate past. In that sense its function I think is to alert others when the socially defined reality is changing in some way, such as when something or someone is being revealled as absurd, when previously esteemed, or vice versa.

I think I heard the funniest joke, people all over the world got was that Sherlock Holmes and Watson were sleeping in the desert, when Sherlock awakes to ask Watson what he deduces looking at the starry sky. Watson launches into this well informed series of deductions ending with the conclusion alien life is probable, to which Sherlock responds "No you idiot, it means someone stole our tent!"

What was certain becomes uncertain, what appeared to be was not, laugh to alert the others, that they may know.
 
  • #9
kolleamm
447
43
I've been reading all of your posts so far in an effort to develop a simple and computationally efficient algorithm. The software has a pretty good understanding of what people usually say such as "how are you?" and "good morning". My idea so far is that when the software identifies a normal phrase with a small alteration to it, it will consider it funny. For example - "bad morning", "how are I?". All obvious in what they mean to say but slightly different.
Avoiding deep branching searches is a major problem in making a software practical however.
 
  • #10
Fooality
196
42
I've been reading all of your posts so far in an effort to develop a simple and computationally efficient algorithm. The software has a pretty good understanding of what people usually say such as "how are you?" and "good morning". My idea so far is that when the software identifies a normal phrase with a small alteration to it, it will consider it funny. For example - "bad morning", "how are I?". All obvious in what they mean to say but slightly different.
Avoiding deep branching searches is a major problem in making a software practical however.

This question kinda stuck in my mind. On further thought, funny very often presents a peice of information with one assumed meaning, then provides a new piece of information that shifts the semantic meaning, or provides new context, of the first information. Thats really ubiquitous in jokes. I can think of a million examples. (Unfortunately most are dirty) The challenge is to have a computational map of symbols to meanings with probabilities, and know the information that will shift a meaning to a less probable meaning.
 
  • Like
Likes NorseMN and kolleamm
  • #11
kolleamm
447
43
This question kinda stuck in my mind. On further thought, funny very often presents a peice of information with one assumed meaning, then provides a new piece of information that shifts the semantic meaning, or provides new context, of the first information. Thats really ubiquitous in jokes. I can think of a million examples. (Unfortunately most are dirty) The challenge is to have a computational map of symbols to meanings with probabilities, and know the information that will shift a meaning to a less probable meaning.
That might have just given me an idea. Specify certain words or phrases that are known to shift meaning, for different categories of sayings such as greetings, farewells etc...and have the software keep an eye out for those.
 
  • #12
Fooality
196
42
Right... Here's one, light: As in beer->(stout, lager, light) becomes light as in physics->(light, matter, energy)

The great physicists of yore were out having beer in the afterlife, when Boyle hollered for another at the waitress as she was walking away. "Dont do that" Newton scolded him. "If you wait for her to be walking toward to when you call for another, her existing momentum and velocity will add to her acceleration toward you to take your order, making less time between your order and beer"

This caused some debate between the physicists as to whether it mattered, but being people of science, they agreed to test it, quietly timing the results between each order, and the direction of the waitress as they made it. When they were done, all the results confirmed Newton's, except for one physicist's orders... Not only were they served faster than all the others, but the speed was the same whether the waitress had been moving away or toward them when made. Perplexed, they asked the physicist with the orders what he thought the reason was for the anomoly.

"Very simple gentlemen" Einstein replied, with a twinkle in his eye. "Its LIGHT beer I ordered"

***
Gawd thats awful, and you have to have know the history of relativity to get it, but I just totally sythesized that joke using that idea I totally think you could do it.
 
  • #13
36,191
8,173
I believe it's very difficult to program a computer to generate humorous responses, as a lot of humor depends on multiple meanings for words. For example,

A dog walks into a bar, and says, "I'm looking for the man who shot my paw!"​

Just to understand this joke, the software needs to understand the dual meanings of the word "paw."

Or, in this one, the software needs to understand the idiomatic expression "long face":

A horse walks into a bar. The bartender says, "Why the long face?"​

Or, the software needs to understand unusual meanings of words:

Q: What's brown and sticky?
A: A stick.​
 
  • #14
kolleamm
447
43
I believe it's very difficult to program a computer to generate humorous responses, as a lot of humor depends on multiple meanings for words. For example,

A dog walks into a bar, and says, "I'm looking for the man who shot my paw!"​

Just to understand this joke, the software needs to understand the dual meanings of the word "paw."

Or, in this one, the software needs to understand the idiomatic expression "long face":

A horse walks into a bar. The bartender says, "Why the long face?"​

Or, the software needs to understand unusual meanings of words:

Q: What's brown and sticky?
A: A stick.​
The problem is not realizing whether or not a statement is a pun or whether or not it has words used in ways that are unusual but make sense, it's that the software needs real world information for example that horses have - long faces. So I believe a software for humor could be made, however the amount of jokes it understand would probably be proportional to it's knowledge of the real world and the slangs people use etc...
 
  • #15
36,191
8,173
The problem is not realizing whether or not a statement is a pun or whether or not it has words used in ways that are unusual but make sense, it's that the software needs real world information for example that horses have - long faces.
It's not just the knowledge that a horse has a long face, but that there's another meaning for "long face." So is it that the horse has a long face (literally, because it's a horse) or it that the horse is sad, the other meaning of having a long face.

Humans can deal with these ambiguities, but computers and their software have a much harder time with ambiguous statements.
kolleamm said:
So I believe a software for humor could be made, however the amount of jokes it understand would probably be proportional to it's knowledge of the real world and the slangs people use etc...

Another one to consider:
A beaver walks into a drinking establishment, and says, "Is the bartender here?"
Even some humans have a hard time with this one... The joke works better if it is spoken than when it is read.
 
  • #16
Fooality
196
42
It's not just the knowledge that a horse has a long face, but that there's another meaning for "long face." So is it that the horse has a long face (literally, because it's a horse) or it that the horse is sad, the other meaning of having a long face.

Humans can deal with these ambiguities, but computers and their software have a much harder time with ambiguous statements.

....

They can do it though. In the case of your last joke, its about about a map of words to phonemes thats reversable. So "bartender here" and "bar tender here" map to the same phonemes, just with different emphasis on syllables (BARtender vs BARTENder). Once you've identified slippery points like this you construct the joke around them. Surely a computer could help.

What I think is interesting is that many jokes do this with the meaning of situations, not just words... So there really is some kind of universal thing at play.
 
  • #17
kolleamm
447
43
If we can define something funny as being unexpected then it would still hold true for the jokes mentioned. For example the beaver joke

A beaver walks into a drinking establishment, and says, "Is the bartender here?"

What's unexpected about these types of jokes is the double meanings to it. It's funny because you don't expect most statements to have double meanings, at least not ones so different from each other.

As for the long face joke about the horse. The software would basically learn from people that horses have unusually long faces, it would not derive such a conclusion from analyzing geometry because in that case practically everything is long in comparison.
 
  • #18
36,191
8,173
As for the long face joke about the horse. The software would basically learn from people that horses have unusually long faces, it would not derive such a conclusion from analyzing geometry because in that case practically everything is long in comparison.

With this logic, the software wouldn't get the joke. After the program "learned" that horses have long faces (relative to human faces), it would still be scratching its head (if software can scratch its head) wondering what was so funny about the length of horses' faces.
 
  • #19
Svein
Science Advisor
Insights Author
2,224
758
“Some logics get nervous breakdowns. Overloaded phone system behaves like frightened child. Mike did not have upsets, acquired sense of humor instead. Low one. If he were a man, you wouldn't dare stoop over. His idea of thigh-slapper would be to dump you out of bed — or put itch powder in pressure suit.”
Robert A. Heinlein, The Moon is a Harsh Mistress

(Mike is a computer)
 
  • #20
kolleamm
447
43
With this logic, the software wouldn't get the joke. After the program "learned" that horses have long faces (relative to human faces), it would still be scratching its head (if software can scratch its head) wondering what was so funny about the length of horses' faces.
It would be funny because the pun would give an unexpected double meaning to the statement made, the horse having a long face by itself wouldn't be the source.
 
  • #21
kolleamm
447
43
“Some logics get nervous breakdowns. Overloaded phone system behaves like frightened child. Mike did not have upsets, acquired sense of humor instead. Low one. If he were a man, you wouldn't dare stoop over. His idea of thigh-slapper would be to dump you out of bed — or put itch powder in pressure suit.”
Robert A. Heinlein, The Moon is a Harsh Mistress

(Mike is a computer)
That's pretty disturbing lol
 
  • #22
Fooality
196
42
http://m.slashdot.org/story/310949

Apropos: The idea that humor is always routed in a semantic switcheroo, even visual and situational humor, implies the idea of a universal language, through which our brains process the world. The link shows this idea is alive and well.
 
  • #23
chiro
Science Advisor
4,797
133
Maybe you should listen to comedians and ask people what they find humorous to answer that question.

I don't know if a simple algorithm can really capture that.

What do you find funny?
 
  • #24
kolleamm
447
43
Maybe you should listen to comedians and ask people what they find humorous to answer that question.

I don't know if a simple algorithm can really capture that.

What do you find funny?
That's actually a really good question you asked. What I find funny is something that is not dangerous and is unexpected. The older you get I guess the less likely you are to laugh since you would have heard a lot of joke types and thus they become predictable.
 
  • #25
chiro
Science Advisor
4,797
133
Humor is a weird thing and with politics - what one group likes is what another group hates.

You can't win with politics - but I guess people try anyway.
 
  • #26
36,191
8,173
What I find funny is something that is not dangerous and is unexpected.
An old quote whose source I am unable to find is this: "Humor is when someone else falls down and breaks his leg. Tragedy is when I fall down and break my leg."
 
  • #27
.Scott
Science Advisor
Homework Helper
2,977
1,235
Code:
bool Statement::isFunny()
{
  if(m_Author == DEVELOPER_ID) {
    if(m_AssertedType == JOKE) {
      m_Type = JOKE;
      m_Response = LAUGH;
      return true;
    }
  }
  ...
}
 
  • #28
kolleamm
447
43
Yes different sides of political parties find different things funny, but their humor still follows the unexpected rule. It really comes down to humor for who do you want to program.
 
  • #29
rootone
3,388
946
Code:
bool Statement::isFunny()
{
  if(m_Author == DEVELOPER_ID) {
    if(m_AssertedType == JOKE) {
      m_Type = JOKE;
      m_Response = LAUGH;
      return true;
    }
  }
  ...
}
I'm not so sure about that.
It would mean that if the author asserts that pushing a random person into a river is funny then our AI should consider the act to be amusing.
 
  • #30
kolleamm
447
43
What I'm starting to see is that there really is no universal humor. It all shares the same characteristic of being unexpected however different people will know different things. Even we have made many jokes I'm sure which the other person did not find funny either because they have heard it too many times or found it insulting.
 
  • #31
.Scott
Science Advisor
Homework Helper
2,977
1,235
I'm not so sure about that.
It would mean that if the author asserts that pushing a random person into a river is funny then our AI should consider the act to be amusing.
But only if the author is the AI developer. Otherwise other code (represented by the ellipsis) would determine whether it was funny.
But this may be a problem. If we want to market this, we should replace DEVELOPER_ID with a global value that can be reconfigured whenever the AI is resold (g_AI_Owner_ID).
 
  • #32
jack action
Science Advisor
Insights Author
Gold Member
2,460
4,964
It's not just the knowledge that a horse has a long face, but that there's another meaning for "long face." So is it that the horse has a long face (literally, because it's a horse) or it that the horse is sad, the other meaning of having a long face.

Humans can deal with these ambiguities, but computers and their software have a much harder time with ambiguous statements.
I think a computer could deal with these ambiguities just as well.

@Mark44 ' statement reminded me of an experiment I read about robot making life or death decisions, where a robot was programmed to keep another robot from falling into a hole. Everything works fine until you put two robots that need to be saved. Which should it choose? Too often, it was changing it's mind so often that it couldn't save either of one.

That is ambiguity. And it could be easy to program AI to recognize it. What's so different about a joke where a sentence could have two meanings? The AI searches its vocabulary and finds the two meanings that have the same value under the given context. It then knows it is a joke. Why? Because the sentence is constructed in such a way that no one can clearly tell which meaning is the right one. That is how a human knows it is funny. If a human (a kid or someone who doesn't master the language for example) doesn't have two references to its knowledge, it won't find the play on words funny either. That is even true for inside jokes.

This is for understanding a joke. Now, about creating one, that might be more difficult ... maybe not. It is probably creating one in the right circumstances that is hard (You shouldn't tell a joke when someone died).
 
  • #33
.Scott
Science Advisor
Homework Helper
2,977
1,235
I think a computer could deal with these ambiguities just as well.

@Mark44That is ambiguity. And it could be easy to program AI to recognize it. What's so different about a joke where a sentence could have two meanings? The AI searches its vocabulary and finds the two meanings that have the same value under the given context. It then knows it is a joke. Why? Because the sentence is constructed in such a way that no one can clearly tell which meaning is the right one. That is how a human knows it is funny. If a human (a kid or someone who doesn't master the language for example) doesn't have two references to its knowledge, it won't find the play on words funny either. That is even true for inside jokes.
That may be a necessary condition for some jokes, but it is not sufficient. Sometimes word play is used to communicate a serious message.
How about this: "There are some things money can't buy. For everything else, there's MasterCard". There's a subtle ambiguity in the first sentence. It can be taken literally, or you can recognize it as a romantic reference to life experiences that transcend economics. The second sentence plays on that ambiguity. Combined, the two sentences follow the same semantic pattern of many jokes - with a setup and a punch line. But the message is not humorous.

Or is it? As you mentioned, context is important. Tell a quick story about a life event you wouldn't want to repeat, then follow it with this slogan as a sudden contrast to the stories in the MasterCard advertising campaign and it could be quite humorous. In this case, the core humor is in the notion of cherishing something that is distasteful - and perhaps the possibility that someone might be sold on that notion.

For AI to tackle this, it needs to be able to listen to the joke, see the ambiguities, determine how those different meanings might threaten or support a human listener, then see a sudden twist in this effect, then recognize that the change in this effect falls within the bounds of humor.

But, do you even need ambiguity. Sometime confrontation works just as well:
http://www.digitalsynopsis.com/wp-content/uploads/2014/08/honest-advertising-slogans-5.jpg
 
  • #34
libervurto
6
4
People talk about different kinds of humour/laughter: nervous laughter, relief, absurdity, surprise, etc. but I think these all boil down to the same thing really, they are all "misapplications" of logic, basically a faulty premise that is taken to its logical conclusion, which is then proven wrong thus revealing the premise was false.

Laughing in relief is for example, you were frightened by a rustling in the bushes, you thought it might be a tiger but it turned out to be a sparrow. You adopted the false premise that the rustling was made by a tiger and you created a threat in your mind based on that only to be proven wrong and your whole line of thought was thus a wayward path. Maybe the rustling really was a tiger and you barely managed to escape it! Then you might also laugh because (thankfully) your logical deduction that you would soon be tiger dinner was proven wrong.

Laughing in surprise is almost exactly the same but with the added layer that initially you didn't suspect a thing, then you get the surprise which might shock you and cause your mind to quickly leap to assumptions about the situation (possibly another phantom tiger!) and then this is proved wrong too. So you are both laughing in relief and laughing at your inability to detect anything was afoot at all.

Nervous laughter happens when you are trying to reassure yourself that you have indeed made a mistake, the situation cannot be as bad as it seems, this must be a joke, right?

Absurdity is I think the purest form of humour, it is the most abstract form of this same "faulty premised" logic. It would be fairly simple to give AI a childish absurdist humour, for example, all you need to do is miscategorise something on purpose, eg, "Q: What type of car does my Dad drive? A: A banana!", we were expecting a type of car but instead got a type of fruit; hilarious, I'm sure you'll agree.

I think the secret to the most effective humour is maintaining the wayward path of reasoning for as long as possible. But this isn't as simple as drawing out our misdirection, eg: "Q: What has four wheels, a horn, a windshield and seats? A: A banana!", none of those descriptors lead us any closer to a banana so we weren't really misled, just delayed. Although the fact I used, "A banana!", again as the answer is kind of amusing, which I guess is funny because if every answer I give is, "A banana!", then everything I say is an illogical conclusion, the whole idea of there being a question with a real answer becomes a misdirection and a faulty premise.

So what if I use the same joke but try to fit an answer that matches the description, then I really will have made a wayward path to follow. "What has four wheels, a horn, goes very fast and is a danger to pedestrians? A rhinoceros riding a skateboard." Now we're getting somewhere, this looks like an actual joke and it has a simple, replicable format: "find two unrelated objects, a combination of whose descriptors are also descriptors of a third object." IN this case a car, a rhino and a skateboard.

Let's give it a go. First find two objects that have a common descriptor but other unmatching descriptors: a cup and a door both have handles but are quite different in other respects. Now find a third object that shares a different characteristic with both. We can also think about combinations, like something that might use a cup or have a door in it, these combinations don't have to make sense (like our rhino on a skateboard). How about a spaceship, a "flying saucer"? That would have a door in it and cups go with saucers. "What has a handle and is usually found on a saucer? A spaceship door." Okay, not a classic but it works. We choose "spaceship door" as the answer because this is the least common of the two possible answers (the other being a cup). In fact the combination is usually going to be the least common answer so it will probably be the funnier of the two.

Let's try another using a door and a cup again. "What has a handle and can be filled with tea? An Englishman with a door in his face.", this requires knowledge of a further connection to appreciate fully: a door and a mouth are both portals. The door replaces the mouth on the face of the man.

The rhino joke works better because the "horn" refers to two very different things in the case of the rhino and the car, so this makes misdirection easier. Utilising this kind of distinction to produce humour requires data that distinguishes between different definitions of the same word. It is clear that a sense of humour requires a lot of detailed data.
 
  • Like
Likes jack action

Suggested for: Programming a sense of humor

  • Last Post
Replies
14
Views
989
  • Last Post
Replies
7
Views
8K
  • Last Post
Replies
21
Views
5K
  • Last Post
Replies
2
Views
711
  • Last Post
Replies
18
Views
3K
Replies
3
Views
3K
  • Last Post
Replies
11
Views
2K
  • Last Post
Replies
6
Views
3K
  • Last Post
Replies
29
Views
3K
Replies
20
Views
2K
Top