Explainable AI Framework for Cognitive and Pragmatic Analysis of Classical Arabic Narratives Using Large Language Models
Classical Arabic narratives present unique challenges in the computational analysis of their texts, due to the language's highly complex morphology, orthographic ambiguity, and stylistic variations over time. This study presents a framework for Explainable Artificial Intelligence (XAI) for cognitive and pragmatic study of Arabic texts with two typical tasks, namely author attribution and Named Entity Recognition (NER). The ground truth used in the framework is not synthetically created, but rather comes from two already available resources, that are sufficiently rich to provide strong, machine-verifiable ground truth: the OpenITI corpus segmented in passages and labeled by the Author URI for multi-class attribution for six classical authors and CLEAN-ANERCorp, a corrected CoNLL format Arabic NER corpus recast as a windowed-context classification task with labels PER, LOC, ORG, MISC and O. The four traditional machine-learning classifiers, Logistic Regression, Multinomial Naive Bayes, Linear Support Vector Machine (SVM), and Random Forest are systematically benchmarked after the normalization and TF-IDF vectorization of the Arabic texts (unigrams and bigrams, vocabulary limited to approximately 8,000 features, minimum document frequency of 1). Models are tested using an 80/20 stratified train-test split, and accuracy, weighted precision, weighted recall, weighted F1-score, Matthews Correlation Coefficient (MCC), and Cohen's Kappa are used to evaluate models. The Linear SVM achieves the best performance with an 80/20 split, with an author-attribution F1 of 0.932 and an NER F1 of 0.809, while an 80/40 split yields an author-attribution F1 of 0.942. The ten most important TF-IDF features are extracted for each class and presented as a pair of Arabic-English word lists, thereby providing algorithmic transparency. Together, the results demonstrate that linear discriminative models and appropriate lexical feature engineering can provide a very accurate and interpretable baseline for the development of natural language processing algorithms for Arabic.