Profanity and Offensiveness Detection in N epali Language Using Bi-directional LSTM Models (2024)

Abstract: Offensive and profane content has been on the rise in Nepali Social Media, which, is very disturbing to users. This is partly due to the absence of proper tools and mechanisms for the Nepali language to deal with profanity and offensive texts. In this work, we attempt to develop a deep learning-based profanity and offensive comments detection tool. We develop a Bi-LSTM (Bidirectional Long Short Term Memory) based model for the classification of Profane and Offensive comments and study different variations of the task. Furthermore, Multilingual BERT embedding and vocab embedding were used among others for an accurate understanding of the intent and decency of the posts. While previous related studies in the Nepali language are more focused on sentiment and offensiveness detection only, our study explores profanity and offensiveness detection as two distinct tasks. Our Bi-LSTM model outputs 87.8% accuracy for

## introduction with the development of technology and affordable access to the internet, the number of users has surged across social media sites like facebook, youtube, x (formerly twitter), reddit, etc. users interact on social media by commenting and posting in natural language. unfortunately, the interaction is not always social and pleasant. internet content is getting more toxic by the day with increasingly profane, offensive, and hateful content flooding in @xcite . thus, detecting and moderating profane and offensive language content is crucial in social media to keep the discussion decent and publicly acceptable. manual detection of foul language in social media platforms with a large user base is costly and timeconsuming. therefore, it is necessary to develop automatic profane and offensive content detection systems @xcite . there are multiple studies conducted in this problem domain, particularly for highresource languages like english (teh and cheng, 2020), german @xcite , and spanish @xcite . however, the problem is not adequately studied for nepali -a lowresource language, albeit a few works of @xcite . the previous works have focused more on abusive sentiment and offensive language detection whereas profanity detection and the gender associations with the problem are underexplored. building on these previous studies, we attempt to detect profanity and offensiveness in nepali, primarily observed in controversial facebook posts. the profanity and offensiveness of text are differentiated with the notion that the presence of taboo words in the abusive text makes it profane while its absence makes it offensive. in this study, we contribute to dataset development by developing an annotated dataset for profane and offensive comments in the nepali language, collected from various contro-versial facebook posts. besides the dataset development, we also propose a bi-lstm (bidirectional long short term memory) modelbased working prototype to handle both binary (profane vs non-profane, offensive vs nonoffensive) and multi-class (offensive vs profane vs none) classification of the comments. furthermore, we study the multi-class classification problem using multilingual bert embedding and vocabulary embedding. in this regard, the key contributions of this study can be summarized as follows: ## related work profanity and offensiveness detection systems have been developed for high-resource languages like english (teh and cheng, 2020), hindi @xcite , german @xcite , and spanish (díaz-torres et al., 2020) but such systems are still under development for low-resource languages like nepali @xcite , sinhala @xcite etc. the study conducted in the mexican spanish language focuses on different categories of abusive texts such as vulgarity, aggressiveness, and offensiveness based on intent and context @xcite . furthermore, the classification of offensive and vulgar language requires a finegrained approach to differentiate the aspects including disability, sexism, racism, etc. (teh and cheng, 2020). profanity is one of such classifications of abusive texts, detection of which is more effective if we associate hatred with profane words (teh and cheng, 2020). the use of curse words is found to have a contextual variable associated with it: when, where, and how, via the research on english language data from x (formerly twitter) @xcite . the variations in how curse words are used negatively affect the profanity detection task resulting in low recall @xcite . even nepali social media texts come in different forms: native (pure devanagari), code-mixed (romanized), and code-switched (roman + devanagari) making it difficult to pre-process @xcite and classify accurately. the study by @xcite provides a way to handle the pre-processing of such nepali text using techniques like dirgikaran and romanization (transliteration) for classification purposes. among the models used for profanity detection, lstm was found to outperform other sequential models like cnn (convolutional neural network), and gru (gated recurrent unit) by studies done in korean @xcite and marathi @xcite languages. with these references as a basis for our research, we decided that lstm architecture would be a better suit to solve our tasks given its capacity for handling sequential tasks and addressing long-term dependencies, in text classification across different linguistic contexts. in the detection of profanity and offensiveness in the nepali language, only a handful of resources and research studies have been conducted @xcite and @xcite . the work of @xcite was conducted for the classification of abusive texts but included only 407 instances of profanity which seems to be insufficient data for the profanity detection task. the work of @xcite has a fine-grained classification of racist, sexist, and others under the broader umbrella of offensive comments but this study does not encompass the profanity-based classification. as a bid to address this research gap in previous studies, we attempt to build a larger dataset for the profanity detection tasks. there are also gender rank factors associated with profanity @xcite , which is not explored in the nepali language. so, we also look into this aspect in our study. ## experimentation and result the studies @xcite and @xcite for profanity detection in lowresourced languages, marathi and korean, respectively, indicate that the lstm model performs better than other sequential models namely: cnn and gru. additionally, the study by (ezen-can, 2020) emphasized that the lstm model performs better than the bert model for a smaller dataset. based on above mentioned studies we selected the baseline bi-lstm model for our experimental setup. the model experimentation and results of different classification tasks are detailed as follows: ## discussion the promising result of the model in task a can be attributed to higher instances (2229) of profane comments on the dataset. the profanity of the comment does not depend on the context as much compared to the offensive words. the common profane words like "मु जी", "फक", "मा चक्ने " etc. are used more frequently. the inferior performance of the model for task b when compared to task a can be attributed to lower instances (1313) of offensive comments for training. also, the offensiveness of the comment depends upon the context and intent. e.g. कु कु र -represents the animal "dog" in the layman's understanding but when the context is of offensive sentiment it represents the person is being insulted as "a dog". furthermore, significant low recall values for the offensive class across models task b, task c(a), and task c(b) indicate that the models make more errors by inaccurately predicting offensive comments as non-offensive, which is due to contextual complexities regarding sentiment associated with offensive comments and their lower instances in the dataset. ## conclusion in this study, we developed an annotated dataset for profanity and offensiveness detection in the nepali language to address the scarcity of labeled datasets. the dataset was developed by labeling 11681 facebook comments collected from various controversial facebook posts. also, we proposed a method to pre-process the social media text via transliteration from romanized english latin script) to devanagari script instead of transliteration from devanagari to romanized english (latin script) as done in the previous study @xcite . the observation from the experiments indicated that the models performed better in the classification of profane comments than offensive comments. it was also noted that the binary classification models outperformed the multi-class classification models. the study also points out that male users are more likely to use offensive and profane language compared to females, supporting the study done by @xcite . the dataset and models developed during this study open doors for future research and eradication of antisocial behavior like bullying, harassment, etc. in social media platforms. the first-level annotated dataset can further be potentially used for hate speech detection. in the future, we plan to enrich and enlarge our dataset by incorporating nepali texts from other social media platforms covering regional slang as well, while implementing the interannotator agreement for better data reliabil-ity. the enlarged dataset is to be further revalidated by experts. we also plan to develop models using advanced architecture, such as transformers, once sufficient data is gathered. we also plan to improvise the pre-processing by introducing the lemmatization technique.