Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can an algorithm detect sarcasm [closed]

Tags:

algorithm

nlp

I was asked to write an algorithm to detect sarcasm but I came across a flaw (or what seems like one) in the logic.

For example if a person says

A: I love Justin Beiber. Do you like him to?

B: Yeah. Sure. I absolutely love him.

Now this may be considered sarcasm or not and the only way to know seems to be to know if B is serious or not.

(I wasn't supposed to be in depth. We were given a bunch of phrases and just were told that if these were in the sentence then it was sarcastic but I got interested?)

Is there any way to work around this? Or are computers absolutely stuck when it comes to sarcasm?

(I suppose it depends on the tone of the speaker but my input is text)

like image 243
cjds Avatar asked Dec 31 '12 04:12

cjds


2 Answers

Looks like there are studies that attempted just that, but they have yet to come up with a well working algorithm.

From González-Ibáñez, R. et al. "Identifying sarcasm in Twitter: a closer look"

Sarcasm and irony are well-studied phenomena in linguistics, psychology and cognitive science[...]. But in the text mining literature, automatic detection of sarcasm is considered a difficult problem [...] and has been addressed in only a few studies. [...] The work most closely related to ours is that of Davidov et al. (2010), whose objective was to identify sarcastic and non-sarcastic utterances in Twitter and in Amazon product reviews. In this paper, we consider the somewhat harder problem of distinguishing sarcastic tweets from non- sarcastic tweets

They conclude:

Perhaps unsurprisingly, neither the human judges nor the machine learning techniques perform very well. [...] Our results suggest that lexical features alone are not sufficient for identifying sarcasm and that pragmatic and contextual features merit further study

Here is another recent, relevant paper:
Reyes, A. "From humor recognition to irony detection: The figurative language of social media"

like image 52
Enno Shioji Avatar answered Oct 24 '22 23:10

Enno Shioji


...sentences are written by users. Its a simulated conversation between 2 people.

Detecting the sarcasm is close to impossible with a single phrase, but with context it might be a little more doable. Let's assume that you can parse the sentence and interpret its literal meaning (not a trivial task, but that problem has been solved at least somewhat).

You now have context from:

  1. All the phrases in the conversation.
  2. The response of the other speaker.

Cross-Referenced Phrases

To leverage #1, you might cross reference all phrases with each other. Are any of them directly contradictory?

Example:

Speaker 1: I LOVE Justin Bieber. Do you?
Speaker 2: Totally! I love him.
Speaker 1: What's your favorite thing about him?
Speaker 2: His awesome music!
Speaker 1: Really? What's your favorite song?
Speaker 2: Come on, you know I hate his music.

We know have two contradictory phrases, "I love him!" and "I hate his music". There's at least a chance sarcasm has occurred.

Question or Response from Other Speaker(s)

Approach #2 could be more effective (or useless...perhaps the sarcasm is known but unspoken between the two parties).

Example:

Speaker 1: Justin Bieber is in town. I am SO going to see him.
Speaker 2: Ha.

Another example:

Speaker 1: I LOVE Justin Bieber. Do you?
Speaker 2: I have a giant poster of him above my bed.
Speaker 1: Yeah right.

Getting even more elaborate, you could apply a heuristic to determine how sharply the conversation deviated after a particular phrase.

Speaker 1: I am so totally into Justin Bieber!!! Are you?
Speaker 1 has made an emphatic statement
Speaker 2: Yeah, sure.
Sarcastic. We don't know that, but the other person in the conversation does.

What direction does Speaker 1 take now? do they change the subject? Depending on how sharply the conversation turns, it may indicate how they reacted to the perceived response.

All that said, most of this would require sophisticated processing and I would expect a very low accuracy rate at best. But it's a fascinating question.

like image 45
Tim M. Avatar answered Oct 24 '22 22:10

Tim M.