Sarcasm detection in online comments using machine learning

Date31 July 2023
Pages213-226
DOIhttps://doi.org/10.1108/IDD-01-2023-0002
Published date31 July 2023
Subject MatterLibrary & information science,Library & information services,Lending,Document delivery,Collection building & management,Stock revision,Consortia
AuthorDaniel Šandor,Marina Bagić Babac
Sarcasm detection in online comments using
machine learning
Daniel Šandor and Marina Bagi
c Babac
Faculty of Electrical Engineering and Computing, University of Zagreb, Zagreb, Croatia
Abstract
Purpose Sarcasm is a linguistic expression that usually carries the opposite meaning of what is being said by words, thus making it diff‌icult for
machines to discover the actual meaning. It is mainly distinguished by the inf‌lection with which it is spoken, with an undercurrent of irony, and is
largely dependent on context, which makes it a diff‌icult task for computational analysis. Moreov er, sarcasm expresses negative sentiments using
positive words, allowing it to easily confuse sentiment analysis models. This paper aims to demonstrate the task of sarc asm detection using the
approach of machine and deep learning.
Design/methodology/approach For the purpose of sarcasm detection, machine and deep learning models were used on a data set consisting of
1.3 million social media comments, including both sarcastic and non-sarcastic comments. The data set was pre-processed using natural language
processing methods, and additional features were extracted and analysed. Several machine learning models, including logistic regression, ridge
regression, linear support vector and support vector machines, along with two deep learning models based on bidirectional long short-term memory
and one bidirectional encoder representations from transformers (BERT)-based model, were implemented, evaluated and compared.
Findings The performance of machine and deep learning models was compared in the task of sarcasm detection, and possible ways of
improvement were discussed. Deep learning models showed more promise, performance-wise, for this type of task. Specif‌ically, a state-of-the-art
model in natural language processing, namely, BERT-based model, outperformed other machine and deep learning models.
Originality/value This study compared the performance of the various machine and deep learning models in the task of sarcasm detection using
the data set of 1.3 million comments from social media.
Keywords Sarcasm, Natural language processing, Machine learning, Deep learning, BERT, Reddit
Paper type Research paper
1. Introduction
Sarcasm detection is the task of identifying whether a given piece
of text is sarcastic or not that has valuable applications in the real
world (Davidov et al.,2010).Forexample,intheworldof
business and marketing, sarcasm is a type of sentiment analysis
task that, among other things, can be used for brand monitoring,
customer feedback analysis, opinion mining and market research
(Puh and Bagi
c Babac, 2023). Although sarcasm can often che at
standard sentiment analysis models, sarcasm detection can be
used to collect truthful information about the general publics
view of a product or brand (Riloff et al.,2013).
The problem of sarcasm detection is challenging because it
involves a complex interplay of linguistic, pragmatic and
contextual factors (Reyes et al., 2012). Sarcasm can be
expressed in many ways, ranging from subtle to overt, and can
depend on a rangeof linguistic and contextual cues (B
aroiu and
Tr
aus
,an-Matu, 2022). For example, sarcasm can be conveyed
using exaggeration, understatement, irony or parody and can
involve a range of linguistic features such as lexical ambiguity,
negation and presupposition(Ashwitha et al., 2021).
A variety of machine learning algorithms have been applied to
the task of sarcasm detection, including naive Bayes, support
vector machines, random forests, recurrent neural networks and
convolutional neural networks (CNNs) (Poria et al.,2016).
These algorithms work by learning to recognize patterns in text
data that are associated with sarcasm (Zhang and Wallace,
2018). On the other hand, the choice of features is an important
factor in sarcasm detection (Arora, 2020). Various features have
been used for sarcasm detection, including lexical, syntactic and
semantic features. Lexical features involve the frequency of
certain words or phrases that are often associated with sarcasm,
while syntactic features involve the use of parts of speech and
other grammatical structures to detect sarcasm (Ghosh et al.,
2018). Semantic features involve the use of word embeddings or
other techniques to capture the meaning of the text.
In recent years, bidirectional encoder representations from
transformers (BERT) has emerged as a state-of-the-art method for
various natural language processing tasks (Devlin et al.,2019),
The current issue and full text archiveof this journal is available on Emerald
Insight at: https://www.emerald.com/insight/2398-6247.htm
Information Discovery and Delivery
52/2 (2024) 213226
Emerald Publishing Limited [ISSN 2398-6247]
[DOI 10.1108/IDD-01-2023-0002]
© Daniel Šandor and Marina Bagi
c Babac. Published by Emerald
Publishing Limited. This article is published under the Creative Commons
Attribution (CC BY 4.0) licence. Anyone may reproduce, distribute,
translate and create derivative works of this article (for both commercial
and non-commercial purposes), subject to full attribution to the original
publication and authors. The full terms of this licence may be seen at
http://creativecommons.org/licences/by/4.0/legalcode
Received 3 January 2023
Revised 11 March 2023
9 June 2023
Accepted 4 July 2023
213

Get this document and AI-powered insights with a free trial of vLex and Vincent AI

Get Started for Free

Start Your Free Trial of vLex and Vincent AI, Your Precision-Engineered Legal Assistant

  • Access comprehensive legal content with no limitations across vLex's unparalleled global legal database

  • Build stronger arguments with verified citations and CERT citator that tracks case history and precedential strength

  • Transform your legal research from hours to minutes with Vincent AI's intelligent search and analysis capabilities

  • Elevate your practice by focusing your expertise where it matters most while Vincent handles the heavy lifting

vLex

Start Your Free Trial of vLex and Vincent AI, Your Precision-Engineered Legal Assistant

  • Access comprehensive legal content with no limitations across vLex's unparalleled global legal database

  • Build stronger arguments with verified citations and CERT citator that tracks case history and precedential strength

  • Transform your legal research from hours to minutes with Vincent AI's intelligent search and analysis capabilities

  • Elevate your practice by focusing your expertise where it matters most while Vincent handles the heavy lifting

vLex

Start Your Free Trial of vLex and Vincent AI, Your Precision-Engineered Legal Assistant

  • Access comprehensive legal content with no limitations across vLex's unparalleled global legal database

  • Build stronger arguments with verified citations and CERT citator that tracks case history and precedential strength

  • Transform your legal research from hours to minutes with Vincent AI's intelligent search and analysis capabilities

  • Elevate your practice by focusing your expertise where it matters most while Vincent handles the heavy lifting

vLex

Start Your Free Trial of vLex and Vincent AI, Your Precision-Engineered Legal Assistant

  • Access comprehensive legal content with no limitations across vLex's unparalleled global legal database

  • Build stronger arguments with verified citations and CERT citator that tracks case history and precedential strength

  • Transform your legal research from hours to minutes with Vincent AI's intelligent search and analysis capabilities

  • Elevate your practice by focusing your expertise where it matters most while Vincent handles the heavy lifting

vLex

Start Your Free Trial of vLex and Vincent AI, Your Precision-Engineered Legal Assistant

  • Access comprehensive legal content with no limitations across vLex's unparalleled global legal database

  • Build stronger arguments with verified citations and CERT citator that tracks case history and precedential strength

  • Transform your legal research from hours to minutes with Vincent AI's intelligent search and analysis capabilities

  • Elevate your practice by focusing your expertise where it matters most while Vincent handles the heavy lifting

vLex

Start Your Free Trial of vLex and Vincent AI, Your Precision-Engineered Legal Assistant

  • Access comprehensive legal content with no limitations across vLex's unparalleled global legal database

  • Build stronger arguments with verified citations and CERT citator that tracks case history and precedential strength

  • Transform your legal research from hours to minutes with Vincent AI's intelligent search and analysis capabilities

  • Elevate your practice by focusing your expertise where it matters most while Vincent handles the heavy lifting

vLex