Week 5: Researching Humor & Developing a Rules-Based Humor Detection Model

Apr 20, 2020


Hi everyone! Welcome back to my blog! I hope everyone is well and staying safe during these difficult times.

Just to recap a bit, during the first two weeks, I followed various tutorials online and got acquainted with the applications I would be using for my project, which include Python (using VSCode), Docker, Flask, and Postman.

Weeks 3 and 4 were primarily spent coding and revising the framework of my project, which is now flexible enough to perform any classification task by training a model, predicting on new data, and testing (finding the accuracy of the model).

And during this week, week 5, I’ve begun to tackle the heart of my project, which really boils down to the question: What makes something funny? In this blog post, I will talk about the following things:

  1. Research
  2. My Rules
  3. Rules in Action
  4. Next Steps



Before I began this project, I thought that it would be nearly impossible to understand what makes something funny. After all, each of us have different interests and beliefs, so while one person might find something hilarious, another might find it incomprehensible, boring, or even offensive.

However, I found that philosophers, scientists, neurologists, and psychologists have all been exploring and researching the science of humor for ages! After conducting much research, I found that there were three leading theories for humor:

1. Superiority Theory

The oldest of the three, the superiority theory was first introduced by Plato and Aristotle. Their theory, in a nutshell, is that you laugh and believe something is funny because it makes you feel superior. As Roger Scruton, a supporter of this theory, contends, “If people dislike being laughed at, it is surely because laughter devalues its object in the subject’s eyes” (in Morreall 1987, 168) [1].

Scary, right? This theory definitely has its flaws – it doesn’t account for why we laugh at puns/wordplay, why we laugh when we make a foolish mistake, and tons of other things not associated with the feeling of superiority. Furthermore, when we do feel superior, often humor is not the natural response (ex: reading about the suffering of the poor).

But before you discount this theory completely, I think you should give it some thought. Really think about it. Why do we find fail videos, which essentially portray others’ misfortunes, so funny? Why do we laugh at others when they make stupid mistakes? If you’re unable to answer these questions (I can’t!), maybe the superiority theory has merit.

2. Relief Theory

After the superiority theory came the relief theory. Many contributed and advocated for this theory, including Sigmund Freud. In essence, he asserts that we laugh to release tension and suppressed feelings. As John Dewey states, “Laughter marks the ending … of a period of suspense, or expectation […] a sudden relaxation of strain, so far as occurring through the medium of the breathing and vocal apparatus… The laugh is thus a phenomenon of the same general kind as the sigh of relief” (1894: 558–559) [1].

Not convinced? Maybe Freud can persuade you. “[Freud’s] example is a story told by Mark Twain in which his brother was building a road when a charge of dynamite went off prematurely, blowing him high into the sky. When the poor man came down far from the work site, he was docked half a day’s pay for being ‘absent from his place of employment‘” [1].

Did you laugh? Why was the story so funny? According to the relief theory, the pity and shock that builds up inside of us while we read the sentence is released at the end, causing us to chuckle [1]. In addition, Freud contends the relief theory explains why we laugh at sexual jokes, why we laugh when someone we dislike makes a fool of himself, along with various other instances [1]. Despite this, similar to the superiority theory, this theory can’t explain why we laugh at puns/wordplay, why we laugh when we make a foolish mistake, and numerous other examples.

3. Incongruity Theory

The incongruity theory is perhaps the more intuitive of the three theories for humor. Arising around the same time as the relief theory, proponents of the incongruity theory argue that we laugh when we’re surprised – when we expect one thing to happen but another occurred. In essence, we laugh when our expectations are violated. Examples “including violations of personal dignity (e.g., slapstick, physical deformities), [violations of] linguistic norms (e.g., unusual accents, malapropisms, [wordplay/puns!]), [violations of] social norms (e.g., eating from a sterile bedpan, strange behaviors), and even [violations of] moral norms (e.g., bestiality, disrespectful behaviors, [and videos of bad robbers 🙂 ])” (McGraw and Warren, “Benign Violations”, Psychological Science, Aug. 2010).

Here are some more funny examples I found:

“Some people just need a high five! In the face. With a chair.”

“Me: I’m gonna lose weight. I’m gonna exercise every day. I’m gonna go on a diet & stick to it. Is that cake?”

“I just realized why I don’t look good in pictures anymore. It’s my face.”

“In 34 years on this planet I’ve learned one very important lesson that I’m going to pass on to you fellas. She can eat your fries. You cannot eat her fries.”

“My favorite part of a road trip is my mom telling me how much gas costs at every exit.”

All of the sentences above are funny, according to the incongruity theory, because you expected to read one thing but instead something completely different happened. Furthermore, this theory seems to explain why we laugh at fail videos, why we laugh at ourselves/others when we/they screw up, and many other instances of humor.

Nevertheless, McGraw noticed a flaw of the incongruity theory: it only applies when the violations are relatively harmless. For instance, we laugh at a video of inexperienced robbers trying to rob a bank, but not at a video of inexperienced robbers making a fool of themselves and then getting shot by policemen. McGraw coins his theory the “Benign Violations Theory,” and it’s the theory that I think best captures why we laugh. It’s difficult for me to think of something that’s funny that this theory can’t explain, but if you can please comment below! Also let me know which theory you think best captures the reason why we laugh! 🙂

There are countless other theories, but I feel these are the three main theories and give you an idea of the in depth research done in this field. If you want to learn more, I encourage you to visit this Stanford article, which analyzes each of the three main theories of humor (and more!) in great detail: https://plato.stanford.edu/entries/humor/ [1].


My Rules

Wowed by my research, I set out determined to implement the Benign Violations Theory. However, while relatively easy for a human to understand, this theory, along with all the other theories, are much more difficult for computers to comprehend and execute. For a computer to be able to execute the Benign Violations theory, it would have to somehow understand what is expected and detect when expectations are benignly broken – not an easy task at all!

Instead of tackling this behemoth of a task, I instead decided to first implement simpler rules, rules easier for computers to understand and execute. I’ve come up with five simpler (but admittedly quite naive!) rules that I hope will be able to adequately detect humor:

1. Contain_funnyword: classifies sentences as funny if it contains a “funny” word or phrase, a word or phrase which is generally associated with humor (though not always!).

Examples of “funny” words: clown, funny, ha, humorous, hysterical, ironic, joke, laugh, lol, photobomb, potty, pirate, prank, priceless, pun, punchline, scream, weird, wordplay, yo, zombies, etc.

Examples of “funny” phrases: what do you call, whats the difference between, roses are red, change a light bulb, knock knock, walks into a bar, yo mama, etc.

2. Contain_notfunnyword: classifies sentences as not funny if it contains a “not funny” word, words generally not associated with humor.

Examples of “not funny” words: agony, angry, anguish, awful, depression, dolor, gravity, grief, heartache, heartbreak, mad, misery, sadness, serious, seriousness, soberness, solemn, somber, sorrow, terrible, terrorism, torment, torture, tragedy, tribulation, unhappiness, woes

3. Contain_funnyword_negator: if there is a “negator” word in front of a “funny” word, outputs the opposite result of rule 1.

Examples of “negator” words: un, not, none, nothing, nobody, nowhere, never, neither, rarely, no

4. Contain_notfunnyword_negator: if there is a “negator” word in front of a “not funny” word, outputs the opposite result of rule 2.

5. Weighted average: takes average of first four rules



Rules in Action

Let’s look at a couple examples to see how my rules work.

1. “Ghost me would do the same stuff as alive me. howl. wander. stand in front of the fridge and stare at all the food im not allowed to eat.”

This sentence would be classified as funny by rule 1 (contain_funnyword), as I’ve considered “howl” a “funny” word. The sentence does not contain a “not funny” word or a negator, so all rules would classify it as funny!

2. “They back the practice of extraordinary rendition in which terrorism suspects are sent for questioning to other countries including some accused of torture.”

The sentence above contains “not funny” words, so it would be classified as not funny by rule 2 (contain_notfunnyword). Since there are no “funny” words or negators in the sentence either, all rules would correctly classify it as not funny!

3. “Not trying to be racist or ignorant but all crocodiles and alligators look alike its weird yo

This sentence is a bit more complex! It contains a “not funny” word (“racist”), so rule 2 would classify it as not funny. However, since a negator (“not”) is present before the “not funny” word, rule 4 would correctly classify it as funny. It also contains “funny” words (“weird,” “yo”). Even though a negator is present, the negator word isn’t directly in front of the “funny” words, so rules 1 & 3 would classify it as funny. Thus, by the average rule, this sentence would be classified as funny.


Next Steps

Now that I have decided on some basic rules for humor detection, it’s time to see how well my rules actually do. To do this, I hope to find a large enough humor dataset containing a fairly large sample of both funny and not funny sentences. With this dataset, I will be able to evaluate my rules and see which best captures humor! I will also work on training a machine learning model to tackle humor detection!

Stay tuned for my next blog post! Stay safe everyone!

2 Replies to “Week 5: Researching Humor & Developing a Rules-Based Humor Detection Model”

  1. Charles T. says:

    By just reading my comment, I hope your humor detection finds me to be the next Dave Chappelle!

    1. Ethan H. says:

      Unfortunately, since the word “humor” is currently a “funny” word and no “not humor” or negator words are present, my five rules would all classify your comment as funny! Guess I have to improve my model…

Leave a Reply