Automatic S anskrit Poetry Classification Based on Kāvyaguṇa (2024)

Abstract: Kāvyaguṇa denotes the syntactic and phonetic attributes or qualities of Sanskrit poetry that enhance its artistic appeal, commonly classified into three categories: Mādhyurya (Sweetness), Oja (Floridity), and Prasāda (Lucidity). This paper presents the Kāvyaguṇa Classifier, a machine learning module, designed to classify Sanskrit literary texts into three distinct guṇas, by employing a diverse range of machine learning algorithms, including Random Forest, Gradient Boosting, XGBoost, Multi-Layer Perceptron and Support Vector Machine. For vectorization, we employed two methods: the neural network-based Word2vec and a custom feature engineering approach grounded in the theoretical understanding of Kāvyaguṇas as described in Sanskrit poetics. The feature engineering model significantly outperformed, achieving an accuracy of up to 90.6%

## introduction natural language processing (nlp) involves the intersection of computer science, artificial intelligence, and computational linguistics, focusing on how computers can understand, interpret, and respond to human languages @xcite . nlp is developing vastly for different languages with data-driven approaches. however, low resource languages face numerous challenges in nlp, including data scarcity, complex morphology, orthographic and historical variations, and a lack of digital resources. these issues, combined with the inadequacy of models designed for other languages, hinder the development of robust nlp solutions for sanskrit. although sanskrit has traditionally been categorized as a low-resource language, its nlp development has gained significant momentum in recent years. this progress can be attributed to the well-defined linguistic theories and the association of modern computational approaches. several computer applications are available for the analysis of the syntactic components of the language @xcite @xcite @xcite @xcite @xcite . the poetic literature of a language reflects the higher intellect of society. sanskrit literature, dating back to the vedic era, has fascinated humanity with its sophisticated aesthetic dimensions. classical sanskrit literature is rich in examples of such poetic expression. understanding and processing this literature require a high level of intellect. ānandavardhana emphasizes the importance of deeper understanding, stating, "simply knowing the words and their meanings does not enable one to fully appreciate poetry; true enjoyment comes to those experts who grasp its deeper essence." foot_0 for machines lacking world knowledge, this becomes a complex task. without advanced methods for the automatic interpretation of implied meanings, machines struggle to process the ornate language accurately. while some progress has been made in the processing of literary regard, machines can more easily analyze aspects where meaning is not deeply embedded. for example, tasks such as meter identification @xcite @xcite , and the identification and analysis of sound figures like yamaka @xcite and anuprāsa @xcite have been successfully achieved. poetry classification is performed using various standards such as sentiment, poetic style, etc. @xcite worked out the classification for sanskrit classical text of kumārasambhava based on meter scansion for authorship criteria. @xcite classified poetry text into emotional states using deep learning techniques. @xcite performed sentimental classification of marathi poems using machine learning. singh et al. (2023) attempted classifying hindi poetry on the phonemic features komala and kathora with the use of learning algorithms using statistical data. @xcite developed punjabi poetry classifiers using different textual features. in this paper, we present a novel approach to classifying poetry based on various features such as lucidity, floridity and sweetness known as the kāvyagun . as (henceforth referred to as gun . a) using various machine learning models. in addition, we discuss the application and comparison of two different methods of vectorization, viz. word2vec and feature engineering. ## background sanskrit poetics is primarily divided into six different schools, viz. rasa (aesthetic flavor), alaṅkāra (figures of speech), rīti (style), dhvani (suggestion), aucitya (propriety), and vakrokti (obliqueness). each of these is based on what they consider the most essential factor in poetry. various elements contribute to the beauty of poetry, and these six schools emphasize the different aspects deemed the most important in the enjoyment of poetry. although gun . a (quality) is not considered a separate school, its role is vital in the enjoyment of poetry, as it catalyzes the experience of rasa, the aesthetic flavor. gun . a literally means "quality" refers to syntactic and phonemic features in the literary text that enhances its overall aesthetic experience. there are several opinions of theoreticians on the number and nature of kāvyagun . as. mainly, there are three kinds of perspectives over the classification of the gun . as found in the tradition. v āmana (6 th century ad) standardised rīti concept. he bestowed the spotlight to ritī in his kāvyālaṅkāra-sūtravr . tti (ks). according to him rīti (style) is the vital element of the kāvya. the rītis are the style of poets, shown through the choice of the syllables which are the smallest part of a word and length of compound words. according to v āmana there are ten śabdagun . as and ten arthagun . as. these ten gun . as of each type have the same name but different attributes according to the category. these are instrumental in identifying the rīti. the features of these gun . as are similar to that of bharata. poets like dan . d . in, b ān . bhat . t . a use complex combinations of syllables and long compounds. three dominant rītis are gaud . ī, pāñcālī and vaidarbhī. gaud . ī rīti abounds in the qualities of oja (floridity) and kānti (polish). foot_1 pāñcālī is endowed with the qualities of mādhurya (sweetness) and saukumārya (softness). foot_2 vaidarbhī diction consists of all the ten gun . as in proportion. foot_3 2. classification with three gun . as the classification consists of three gun . as, viz. mādhurya (sweetness), oja (floridity), and prasāda (lucidity)-was introduced by bh āmaha. in his kāvyālam . kāra (4th century ad), bh āmaha explains these three qualities in terms of their syntactic characteristics, although he does not explicitly label them as gun . as. instead, these qualities represent the essential attributes that a poet must employ to express sweetness, floridity, and lucidity in their work. bh āmaha and others linked the concept of gun . as with rasa (aesthetic experience), unlike theorists who regarded rīti (style) as the soul of poetry. according to this view, gun . as help enhance and prepare the reader's mind for the experience of rasa. this approach was later followed by eminent scholars like ānandavardhana and mammat . a. mammat . a (11 th ad), while defining kāvya (poetry), emphasized the inclusion of gun . as as essential elements. 5 he not only advo-cated the threefold classification of gun . as but also provided a rationale for not considering the ten types of gun . as outlined by earlier scholars. according to mammat . a, śles . a, samādhi, udāratā, and prasāda, as defined by v āmana, are subsumed under oja. mādhurya remains as it is, while v āmana's arthavyakti corresponds to mammat . a's prasāda. v āmana's samatā refers to uniformity in writing, which can sometimes be a flaw, as a poet needs to adapt their style to suit the mood of the events described in the kāvya. saukumārya (softness) is understood as the absence of harshness, and kānti (polish) is regarded as the absence of vulgarity. ## implementation and algorithm in the previous section, we discussed the characteristics of gun . as as defined in the treatises of sanskrit poetics. for individuals, it can be challenging to focus on and recall these nuanced features, as a human mind often processes these poetic effects collectively, intuitively, to classify poetry into the respective gun . as. despite clearly defined rules and boundaries, rule-based systems struggle to handle the inherent uncertainty and complexity of sanskrit poetry. moreover, there is currently no model capable of effectively processing such poetry without ## error analysis oja is characterized by its complexity, while prasāda is associated with simplicity. in contrast, mādhurya, with its soft combinations of consonants and a moderate level of complexity, occupies a midpoint between these two gun . as. even for a human annotator, it is tricky to classify the ślokas, especially those identified as failed cases, into a definitive gun . a. this observation provides a plausible explanation for the misclassifications, as texts exhibiting mādhurya may sometimes share features with oja and prasāda. this discrepancy opens avenues for further exploration. future research could address this issue by employing multilabel classification techniques, allowing texts to be assigned to one or more gun . as based on their dominant features. in ## comparision of feature engineering with word2vec word2vec is a widely used unsupervised learning technique that captures semantic relationships between words by mapping them into continuous vector spaces. however, in our task of classifying sanskrit poetry into gun . as, we observed certain limitations when relying solely on word2vec embeddings. the low score with the word2vec model can be attributed to the limited size of the training data. models like word2vec typically require large datasets, often in the thousands or even millions of examples, to perform effectively. additionally, the vector sizes used in such models usually range from hundreds to thousands, demanding powerful computational resources. training on smaller datasets with limited resources poses significant challenges. despite these constraints, our approach of training the model on minimal data with available resources has produced commendable results, highlighting the effectiveness of the feature engineering technique. the custom feature engineering method is specifically tailored to the nuances of sanskrit poetics. by incorporating features which indirectly reflect morphological structure, consideration of metrical patterns, and stylistic markers, our model was able to better capture the inherent characteristics that define different gun . as. this domain-specific approach resulted in higher accuracy compared to the more general-purpose word2vec embeddings. ## conclusion the computational processing of poetic language presents significant challenges. to address these complexities, we introduced the module 'kāvyagun . a classifier', designed to classify literary texts into three distinct gun . as: mādhurya, oja, and prasāda. for this task, we explain two different approaches used for vectorization. word2vec is useful for capturing semantic information, our custom feature engineering leveraged expert knowledge of the literary domain, allowing a more precise classification in this context. this demonstrates that, in specialized tasks like the classification of sanskrit poetry, combining traditional machine learning techniques with domain-specific insights can offer significant advantages over purely data-driven methods. this module not only serves its primary purpose, but can also be adapted for related tasks. as discussed previously, these gun . as are essential components of both rītis and rasas. the rītis reflect the stylistic inheritance of poets, while the rasas encapsulate the emotions arising from aesthetic experiences. the interplay of gun . as in these contexts is crucial, making the kāvyagun . a classifier a valuable tool for identifying both rītis and rasas. moreover, given the linguistic similarities between sanskrit and other indian languages, their grammatical structures and poetic traditions are deeply influenced by sanskrit. concepts analogous to kāvyagun . a can be found in these languages as well. by employing language-specific training data and adapting feature extraction methodologies accordingly, similar classification tasks can be effectively achieved across various indian languages.