Skip to main content
Log in

Deep Contextualised Text Representation and Learning for Sarcasm Detection

  • Research Article-Computer Engineering and Computer Science
  • Published:
Arabian Journal for Science and Engineering Aims and scope Submit manuscript

Abstract

These days, the world has become a non-denominational place due to cyberspace. Digital services such as search portals and social platforms have become intricate with the regular course of daily life. As a massive number of clients’ thoughts are available on the internet, sentiment analysis has become one of the most prolific investigation arenas in natural language processing. Sarcasm detection is a vital phase in sentiment analysis because of the intrinsically vague nature of sarcasm. To subsidize as a resolution to the current ever-increasing arena of attention on the ever-increasing volume of digital data, this work proposes a novel voting-based ensemble approach for sarcasm detection utilizing deep learning techniques. This paper uses Bidirectional Encoder Representations from Transformers to build contextual word embeddings and feeds those to the network, which is an ensemble of four deep learning models. Convolutional Neural Network, Bidirectional Long Short-Term Memory, and parallel and sequential combinations of both are among the models. For classification, the acquired features from each model are experimented with four machine learning classifiers, such as Support Vector Machine, Least Squares Support Vector Machine, Multinomial Naive Bayes, and Random Forest, along with Sigmoid activation function. Out of these five, the optimal classifier is selected for each model. Finally, a majority voting is performed on the outputs of all four models to differentiate between sarcastic and non-sarcastic texts. The proposed approach has been assessed using two benchmark datasets containing English-language texts, namely, news headlines and the self-annotated reddit corpus. Experiments demonstrated that the proposed methodology produces an accuracy of 94.89% on the news headlines repository, which is a gain of 2.99%, and an F1-score of 80.49% on the self-annotated reddit corpus, which is an improvement of 0.52% over the previous state-of-the-art methodologies.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5
Fig. 6
Fig. 7
Fig. 8
Fig. 9

Similar content being viewed by others

Notes

  1. https://www.kaggle.com/datasets/rmisra/news-headlines-dataset-for-sarcasm-detection.

  2. https://www.kaggle.com/datasets/danofer/sarcasm.

References

  1. Pang, B.; Lee, L.: Opinion mining and sentiment analysis. Found. Trends® Inf. Retriev. 2(1–2), 1–135 (2008)

  2. Bharti, S.K.; Vachha, B.; Pradhan, R.; Babu, K.S.; Jena, S.K.: Sarcastic sentiment detection in tweets streamed in real time: a big data approach. Digit. Commun. Netw. 2(3), 108–121 (2016)

    Article  Google Scholar 

  3. Parmar, K.; Limbasiya, N.; Dhamecha, M.: Feature based Composite Approach for Sarcasm Detection using MapReduce. In: 2018 Second International Conference on Computing Methodologies and Communication (ICCMC), pp. 587–591. IEEE (2018)

  4. Feldman, R.: Techniques and applications for sentiment analysis. Commun. ACM 56(4), 82–89 (2013)

    Article  Google Scholar 

  5. Gautam, G.; Yadav, D.: Sentiment analysis of Twitter data using machine learning approaches and semantic analysis. In: 2014 7th International Conference on Contemporary Computing (IC3), pp. 437–442. IEEE (2014)

  6. Saha, S.; Yadav, J.; Ranjan, P.: Proposed approach for sarcasm detection in Twitter. Indian J. Sci. Technol. 10(25), 1–8 (2017)

    Article  Google Scholar 

  7. Attardo, S.: Irony as relevant inappropriateness. J. Pragmat. 32(6), 793–826 (2000)

    Article  Google Scholar 

  8. Gibbs, R.W.: Irony in talk among friends. Metaphor. Symb. 15(1–2), 5–27 (2000)

    Article  Google Scholar 

  9. Tepperman, J.; Traum, D.R.; Narayanan, S.S.: “yeah Right": Sarcasm Recognition for Spoken Dialogue Systems. In: Interspeech (2006)

  10. Joshi, A.; Bhattacharyya, P.; Carman, M.J.: Automatic sarcasm detection: a survey. ACM Comput. Surv. 50(5), 1–22 (2017)

    Article  Google Scholar 

  11. Rush, A.M.; Chopra, S.; Weston, J.: A Neural Attention Model for Abstractive Sentence Summarization. In: Proceedings of the 2015 Conference on Empirical Methods in Natural Language Processing, pp. 379–389. Association for Computational Linguistics, Lisbon (2015)

  12. Lample, G.; Ballesteros, M.; Subramanian, S.; Kawakami, K.; Dyer, C.: Neural Architectures for Named Entity Recognition. In: Proceedings of the 2016 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pp. 260–270. Association for Computational Linguistics, San Diego (2016)

  13. Yu, X.-M.; Feng, W.-Z.; Wang, H.; Chu, Q.; Chen, Q.: An attention mechanism and multi-granularity-based Bi-LSTM model for Chinese Q &A system. Soft. Comput. 24(8), 5831–5845 (2020)

    Article  Google Scholar 

  14. Berrichi, S.; Mazroui, A.: Addressing limited vocabulary and long sentences constraints in English–Arabic neural machine translation. Arab. J. Sci. Eng. 46(9), 8245–8259 (2021)

    Article  Google Scholar 

  15. Tomer, M.; Kumar, M.: Improving text summarization using ensembled approach based on fuzzy with LSTM. Arab. J. Sci. Eng. 45(12), 10743–10754 (2020)

    Article  Google Scholar 

  16. Hermann, K.M.; Kocisky, T.; Grefenstette, E.; Espeholt, L.; Kay, W.; Suleyman, M.; Blunsom, P.: Teaching machines to read and comprehend. Adv. Neural Inf. Process. Syst. 28, 1 (2015)

    Google Scholar 

  17. Rani, M.S.; Subramanian, S.: Attention mechanism with gated recurrent unit using convolutional neural network for aspect level opinion mining. Arab. J. Sci. Eng. 45(8), 6157–6169 (2020)

    Article  Google Scholar 

  18. Van Hee, C.; Lefever, E.; Hoste, V.: Exploring the fine-grained analysis and automatic detection of irony on Twitter. Lang. Resour. Eval. 52(3), 707–731 (2018)

    Article  Google Scholar 

  19. Kumar, A.; Sangwan, S.R.; Arora, A.; Nayyar, A.; Abdel-Basset, M.: Sarcasm detection using soft attention-based bidirectional long short-term memory model with convolution network. IEEE Access 7, 23319–23328 (2019)

    Article  Google Scholar 

  20. Ptáček, T.; Habernal, I.; Hong, J.: Sarcasm detection on Czech and English Twitter. In: Proceedings of COLING 2014, the 25th International Conference on Computational Linguistics: Technical Papers, pp. 213–223 (2014)

  21. Sulis, E.; Farías, D.I.H.; Rosso, P.; Patti, V.; Ruffo, G.: Figurative messages and affect in Twitter: differences between# irony,# sarcasm and# not. Knowl.-Based Syst. 108, 132–143 (2016)

    Article  Google Scholar 

  22. Uddin, M.N.; Li, B.; Ali, Z.; Kefalas, P.; Khan, I.; Zada, I.: Software defect prediction employing BiLSTM and BERT-based semantic feature. Soft Comput. 1, 1–15 (2022)

    Google Scholar 

  23. Yuan, L.: A joint method for Chinese word segmentation and part-of-speech labeling based on deep neural network. Soft. Comput. 26(12), 5607–5616 (2022)

    Article  Google Scholar 

  24. Riloff, E.; Qadir, A.; Surve, P.; De Silva, L.; Gilbert, N.; Huang, R.: Sarcasm as contrast between a positive sentiment and negative situation. In: Proceedings of the 2013 Conference on Empirical Methods in Natural Language Processing, pp. 704–714 (2013)

  25. Kreuz, R.; Caucci, G.: Lexical influences on the perception of sarcasm. In: Proceedings of the workshop on computational approaches to figurative language, pp. 1–4. Association for Computational Linguistics, Rochester, New York (2007)

  26. Maynard, D.G.; Greenwood, M.A.: Who cares about Sarcastic Tweets? Investigating the Impact of Sarcasm on Sentiment Analysis. In: LREC 2014 Proceedings (2014). ELRA

  27. Cunningham, H.; Maynard, D.; Bontcheva, K.; Tablan, V.: GATE: an Architecture for Development of Robust HLT applications. In: Proceedings of the 40th Annual Meeting of the Association for Computational Linguistics, pp. 168–175 (2002)

  28. Davidov, D.; Tsur, O.; Rappoport, A.: Semi-Supervised Recognition of Sarcasm in Twitter and Amazon. In: Proceedings of the Fourteenth Conference on Computational Natural Language Learning, pp. 107–116 (2010)

  29. Tsur, O.; Davidov, D.; Rappoport, A.: ICWSM—a great catchy name: semi-supervised recognition of sarcastic sentences in online product reviews. In: 4th International AAAI conference on weblogs and social media (2010)

  30. González-Ibáñez, R.; Muresan, S.; Wacholder, N.: Identifying sarcasm in Twitter: a closer look. In: Proceedings of the 49th annual meeting of the association for computational linguistics: human language technologies, pp. 581–586 (2011)

  31. Reyes, A.; Rosso, P.; Buscaldi, D.: From humor recognition to irony detection: the figurative language of social media. Data Knowl. Eng. 74, 1–12 (2012)

    Article  Google Scholar 

  32. Barbieri, F.; Saggion, H.; Ronzano, F.: Modelling sarcasm in Twitter, a novel approach. In: Proceedings of the 5th Workshop on Computational Approaches to Subjectivity, Sentiment and Social Media Analysis, pp. 50–58 (2014)

  33. Liu, P.; Chen, W.; Ou, G.; Wang, T.; Yang, D.; Lei, K.: Sarcasm detection in social media based on imbalanced classification. In: International Conference on Web-Age Information Management, pp. 459–471. Springer (2014)

  34. Joshi, A.; Sharma, V.; Bhattacharyya, P.: Harnessing context incongruity for sarcasm detection. In: Annual Meeting of the Association for Computational Linguistics (2015)

  35. Rajadesingan, A.; Zafarani, R.; Liu, H.: Sarcasm detection on Twitter: a behavioral modeling approach. In: Proceedings of the 8th ACM International Conference on Web Search and Data Mining, pp. 97–106 (2015)

  36. Fersini, E.; Pozzi, F.A.; Messina, E.: Detecting irony and sarcasm in microblogs: the role of expressive signals and ensemble classifiers. In: 2015 IEEE International Conference on Data Science and Advanced Analytics (DSAA), pp. 1–8 (2015). IEEE

  37. Hernández-Farías, I.; Benedí, J.-M.; Rosso, P.: Applying Basic Features from Sentiment Analysis for Automatic Irony Detection. In: Iberian Conference on Pattern Recognition and Image Analysis, pp. 337–344 (2015)

  38. Bamman, D.; Smith, N.A.: Contextualized Sarcasm Detection on Twitter. In: International Conference on Web and Social Media, vol. 9, pp. 574–577 (2015)

  39. Altrabsheh, N.; Cocea, M.; Fallahkhair, S.: Detecting Sarcasm from Students’ Feedback in Twitter. In: European Conference on Technology Enhanced Learning, pp. 551–555. Springer (2015)

  40. Bouazizi, M.; Ohtsuki, T.O.: A pattern-based approach for sarcasm detection on Twitter. IEEE Access 4, 5477–5488 (2016)

    Article  Google Scholar 

  41. Lukin, S.; Walker, M.: Really? Well. Apparently bootstrapping improves the performance of sarcasm and nastiness classifiers for online dialogue. arXiv preprint arXiv:1708.08572 (2017)

  42. Tungthamthiti, P.; Shirai, K.; Mohd, M.: Recognition of sarcasms in Tweets based on concept level sentiment analysis and supervised learning approaches. In: Proceedings of the 28th Pacific Asia Conference on Language, Information and Computing, pp. 404–413 (2014)

  43. Ghosh, D.; Guo, W.; Muresan, S.: Sarcastic or not: word embeddings to predict the literal or sarcastic meaning of words. In: Proceedings of the 2015 Conference on Empirical Methods in Natural Language Processing, pp. 1003–1012 (2015)

  44. Barbieri, F.; Ronzano, F.; Saggion, H.: UPF-taln: SemEval 2015 Tasks 10 and 11. Sentiment Analysis of Literal and Figurative Language in Twitter. In: Proceedings of the 9th International Workshop on Semantic Evaluation (SemEval 2015), pp. 704–708 (2015)

  45. Tungthamthiti, P.; Shirai, K.; Mohd, M.: Recognition of Sarcasm in Microblogging Based on Sentiment Analysis and Coherence Identification. J. Nat. Lang. Process. 23, 383–405 (2016)

    Article  Google Scholar 

  46. Reyes, A.; Rosso, P.: Making objective decisions from subjective data: detecting irony in customer reviews. Decis. Support Syst. 53(4), 754–760 (2012)

    Article  Google Scholar 

  47. Sarsam, S.M.; Al-Samarraie, H.; Alzahrani, A.I.; Wright, B.: Sarcasm detection using machine learning algorithms in Twitter: a systematic review. Int. J. Mark. Res. 62(5), 578–598 (2020)

    Article  Google Scholar 

  48. Suykens, J.A.; Vandewalle, J.: Least squares support vector machine classifiers. Neural Process. Lett. 9(3), 293–300 (1999)

    Article  Google Scholar 

  49. Felbo, B.; Mislove, A.; Søgaard, A.; Rahwan, I.; Lehmann, S.: Using millions of emoji occurrences to learn any-domain representations for detecting sentiment, emotion and sarcasm. arXiv preprint arXiv:1708.00524 (2017)

  50. Mehndiratta, P.; Soni, D.: Identification of sarcasm using word embeddings and hyperparameters tuning. J. Discrete Math. Sci. Cryptogr. 22(4), 465–489 (2019)

    Article  Google Scholar 

  51. Shrivastava, M.; Kumar, S.: A pragmatic and intelligent model for sarcasm detection in social media text. Technol. Soc. 64, 101489 (2021)

    Article  Google Scholar 

  52. Gregory, H.; Li, S.; Mohammadi, P.; Tarn, N.; Draelos, R.; Rudin, C.: A Transformer Approach to Contextual Sarcasm Detection in Twitter. In: Proceedings of the Second Workshop on Figurative Language Processing, pp. 270–275 (2020)

  53. Reyes, A.; Rosso, P.; Veale, T.: A multidimensional approach for detecting irony in Twitter. Lang. Resour. Eval. 47(1), 239–268 (2013)

    Article  Google Scholar 

  54. Ghosh, A.; Li, G.; Veale, T.; Rosso, P.; Shutova, E.; Barnden, J.; Reyes, A.: SemEval-2015 Task 11: Sentiment Analysis of Figurative Language in Twitter. In: Proceedings of the 9th International Workshop on Semantic Evaluation (SemEval 2015), pp. 470–478 (2015)

  55. Filatova, E.: Irony and Sarcasm: Corpus Generation and Analysis Using Crowdsourcing. In: LREC, pp. 392–398. Citeseer (2012)

  56. Wallace, B.C.; Choe, D.K.; Charniak, E.: Sparse, contextually informed models for irony detection: exploiting user communities, entities and sentiment. In: Proceedings of the 53rd Annual Meeting of the Association for Computational Linguistics and the 7th International Joint Conference on NLP, pp. 1035–1044 (2015)

  57. Khodak, M.; Saunshi, N.; Vodrahalli, K.: A large self-annotated corpus for sarcasm. arXiv preprint arXiv:1704.05579 (2017)

  58. Joshi, A.; Tripathi, V.; Bhattacharyya, P.; Carman, M.J.: Harnessing sequence labeling for sarcasm detection in dialogue from TV series ‘Friends’. In: CoNLL, pp. 146–155 (2016)

  59. Misra, R.; Arora, P.: Sarcasm detection using hybrid neural network. arXiv preprint arXiv:1908.07414 (2019)

  60. Mikolov, T.; Chen, K.; Corrado, G.; Dean, J.: Efficient estimation of word representations in vector space. arXiv preprint arXiv:1301.3781 (2013)

  61. Pennington, J.; Socher, R.; Manning, C.D.: GloVe: global vectors for word representation. In: Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP), pp. 1532–1543 (2014)

  62. Bojanowski, P.; Grave, E.; Joulin, A.; Mikolov, T.: Enriching Word Vectors with Subword Information. Trans. Assoc. Comput. Ling. 5, 135–146 (2017)

    Google Scholar 

  63. Devlin, J.; Chang, M.-W.; Lee, K.; Toutanova, K.: BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding. arXiv preprint arXiv:1810.04805 (2018)

  64. Liu, L.; Wang, M.; Zhang, M.; Qing, L.; He, X.: UAMNer: uncertainty-aware multimodal named entity recognition in social media posts. Appl. Intell. 52(4), 4109–4125 (2022)

    Article  Google Scholar 

  65. Ahuja, R.; Sharma, S.: Transformer-based word embedding with CNN model to detect sarcasm and irony. Arab. J. Sci. Eng. 1, 1–14 (2021)

  66. Alzubi, J.A.; Jain, R.; Singh, A.; Parwekar, P.; Gupta, M.: COBERT: COVID-19 question answering system using BERT. Arab. J. Sci. Eng. 1, 1–11 (2021)

    Google Scholar 

  67. Yang, J.; Wang, M.; Zhou, H.; Zhao, C.; Zhang, W.; Yu, Y.; Li, L.: Towards Making the Most of BERT in Neural Machine Translation. In: Proceedings of the AAAI Conference on Artificial Intelligence, vol. 34, pp. 9378–9385 (2020)

  68. Liu, Y.; Lapata, M.: Text Summarization with Pretrained Encoders. arXiv preprint arXiv:1908.08345 (2019)

  69. Niu, X.-X.; Suen, C.Y.: A novel hybrid CNN-SVM classifier for recognizing handwritten digits. Pattern Recogn. 45(4), 1318–1325 (2012)

    Article  ADS  Google Scholar 

  70. Zhou, C.; Sun, C.; Liu, Z.; Lau, F.: A C-LSTM neural network for text classification. arXiv preprint arXiv:1511.08630 (2015)

  71. Ertam, F.; Aydın, G.: Data classification with deep learning using Tensorflow. In: 2017 International Conference on Computer Science and Engineering (UBMK), pp. 755–758 (2017). IEEE

  72. Shrikhande, P.; Setty, V.; Sahani, A.: Sarcasm Detection in Newspaper Headlines. In: 2020 IEEE 15th International Conference on Industrial and Information Systems (ICIIS), pp. 483–487 (2020). IEEE

  73. Pandey, R.; Kumar, A.; Singh, J.P.; Tripathi, S.: Hybrid attention-based Long Short-Term Memory network for sarcasm identification. Appl. Soft Comput. 106, 107348 (2021)

    Article  Google Scholar 

  74. Jamil, R.; Ashraf, I.; Rustam, F.; Saad, E.; Mehmood, A.; Choi, G.S.: Detecting sarcasm in multi-domain datasets using convolutional neural networks and long short term memory network model. PeerJ. Comput. Sci. 7, 645 (2021)

    Article  Google Scholar 

  75. Akula, R.; Garibay, I.: Interpretable multi-head self-attention architecture for sarcasm detection in social media. Entropy 23(4), 394 (2021)

    Article  ADS  PubMed  PubMed Central  Google Scholar 

  76. Sharma, D.K.; Singh, B.; Garg, A.: An ensemble model for detecting sarcasm on social media. In: 2022 9th International Conference on Computing for Sustainable Global Development (INDIACom), pp. 743–748. IEEE (2022)

  77. Hazarika, D.; Poria, S.; Gorantla, S.; Cambria, E.; Zimmermann, R.; Mihalcea, R.: CASCADE: contextual sarcasm detection in online discussion forums. In: Proceedings of the 27th International Conference on Computational Linguistics, pp. 1837–1848 (2018)

  78. Ilić, S.; Marrese-Taylor, E.; Balazs, J.; Matsuo, Y.: Deep contextualized word representations for detecting sarcasm and irony. In: Proceedings of the 9th Workshop on Computational Approaches to Subjectivity, Sentiment and Social Media Analysis, pp. 2–7 (2018)

  79. Savini, E.; Caragea, C.: A Multi-task learning approach to sarcasm detection (student abstract). In: AAAI Conference on Artificial Intelligence (2020)

  80. Kumar, A.; Narapareddy, V.T.; Gupta, P.; Srikanth, V.A.; Neti, L.B.M.; Malapati, A.: Adversarial and auxiliary features-aware BERT for sarcasm detection. In: Proceedings of the 3rd ACM India joint international conference on data science & management of data (8th ACM IKDD CODS & 26th COMAD), pp. 163–170 (2021)

  81. Savini, E.; Caragea, C.: Intermediate-task transfer learning with BERT for sarcasm detection. Mathematics 10(5), 844 (2022)

    Article  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Ravi Teja Gedela.

Rights and permissions

Springer Nature or its licensor (e.g. a society or other partner) holds exclusive rights to this article under a publishing agreement with the author(s) or other rightsholder(s); author self-archiving of the accepted manuscript version of this article is solely governed by the terms of such publishing agreement and applicable law.

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Gedela, R.T., Baruah, U. & Soni, B. Deep Contextualised Text Representation and Learning for Sarcasm Detection. Arab J Sci Eng 49, 3719–3734 (2024). https://doi.org/10.1007/s13369-023-08170-4

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s13369-023-08170-4

Keywords

Navigation