Back to all projects
Computer Science

Sentiment Analysis of Nigerian Social Media Discourse Using NLP

Admin 0 views 0 downloadsBSc/BA

Notice: This is a sample project for study and reference. Submitting it as your own work violates most universities' academic integrity policies.

Abstract

About This Research Topic

Scroll through X (formerly Twitter) during any major Nigerian news cycle — an election, a subsidy announcement, a currency policy shift — and you will find opinion coming in fast, in large volume, and in a mix of English, Nigerian Pidgin, and phrases borrowed from Hausa, Igbo, and Yoruba, often within the same sentence. That mix is exactly what makes Nigerian social media discourse so hard for standard sentiment analysis tools, most of which are trained on tidy, monolingual English text and stumble the moment code-switching, slang, and informal spelling enter the picture. For students exploring a similarly grounded NLP topic, ScholarNest's computer science project topics page is a good place to compare related project ideas in applied machine learning and language processing.

This article breaks down a complete undergraduate research project built around that exact problem: an NLP pipeline that reads Nigerian social media posts and classifies their sentiment as positive, negative, or neutral. Rather than testing one model on convenient data, the study collects and manually annotates its own topic-focused dataset, then benchmarks three model families — classical machine learning, a BiLSTM, and a fine-tuned multilingual BERT (mBERT) — before deploying the strongest performer inside a topic-monitoring web dashboard. What follows walks through the study's background, problem statement, objectives, and scope, for students, researchers, and anyone curious about how NLP is adapting to Nigeria's linguistically layered social media conversation.

Main Abstract

Social media platforms, particularly X, have become a dominant space for Nigerians to weigh in on political, economic, and social issues, generating a volume of unstructured text that is simply impractical to read and interpret by hand. Understanding the sentiment carried in this discourse matters to policymakers, businesses, and researchers alike, but automated sentiment analysis of Nigerian social media text is complicated by widespread code-switching between English, Nigerian Pidgin, and indigenous languages such as Hausa, Igbo, and Yoruba, plus informal spelling, slang, and heavy use of hashtags and emojis.

This study designs, implements, and evaluates an NLP pipeline for classifying the sentiment of Nigerian social media posts as positive, negative, or neutral. The work follows a Design Science Research methodology paired with the CRISP-DM process for its data-driven components. A dataset of 12,500 tweets tied to prominent Nigerian discourse topics — the 2023 general election, the fuel subsidy removal, and the Naira redesign policy — was collected via the X API and a Python scraping pipeline, manually annotated by three independent annotators using a majority-vote labelling scheme, and cleaned through a preprocessing pipeline that handled hashtags, mentions, emojis, and Nigerian Pidgin-aware tokenisation. Three model classes were trained and compared: classical baselines (Naive Bayes and Support Vector Machine) using TF-IDF features, a Bidirectional LSTM network with trainable word embeddings, and a fine-tuned multilingual BERT (mBERT) transformer.

The fine-tuned transformer model came out on top, reaching 84.7% accuracy and an 83.1% macro-averaged F1-score, ahead of the BiLSTM (79.4% accuracy) and both classical baselines (SVM at 74.2%, Naive Bayes at 68.9%). Error analysis showed that most misclassifications fell into the neutral class or involved tweets with heavy Nigerian Pidgin or code-mixed content, which lines up with the broader low-resource status of these language varieties. The trained model was deployed behind a Flask web dashboard that lets a user submit a topic or hashtag and view an aggregated sentiment breakdown and trend chart drawn from recently collected tweets. Testing showed an average inference time of 0.18 seconds per tweet on a standard CPU-based server. The study concludes that transformer-based multilingual models currently offer the most practical route to reasonably accurate sentiment analysis of Nigerian social media discourse, and recommends further work on expanding annotated data for Nigerian Pidgin and indigenous languages to close the remaining performance gap on code-mixed content.

Chapter One Preview

Background to the Study

The rapid growth of social media usage in Nigeria has turned platforms such as X, Facebook, and Instagram into vibrant spaces for public discourse on political, economic, and social issues. Major national events, including general elections, fuel subsidy policy changes, and currency redesign, routinely generate large volumes of posts within days, offering a broad, near real-time cross-section of public opinion. The Reuters Institute's coverage of Nigeria's media landscape points to a highly digital audience and a fast-growing social media ecosystem as defining features of how Nigerians encounter news and opinion today, which is exactly the environment this kind of dataset is drawn from.

Sentiment analysis, the task of automatically determining whether a piece of text expresses a positive, negative, or neutral attitude, has been extensively studied for high-resource languages such as English. Nigerian social media discourse, however, presents distinctive challenges: posts frequently code-switch between English, Nigerian Pidgin, and indigenous languages such as Hausa, Igbo, and Yoruba within a single sentence, and make heavy use of informal spelling, slang, hashtags, and emojis. Models trained purely on standard English sentiment corpora tend to perform poorly on this kind of text, which is what motivated dedicated dataset efforts such as NaijaSenti and AfriSenti.

The NaijaSenti research project, for instance, introduced the first large-scale, human-annotated Twitter sentiment dataset covering Hausa, Igbo, Nigerian Pidgin, and Yorùbá, explicitly built to include a significant share of code-mixed tweets, and found that language-specific models and language-adaptive fine-tuning generally performed best on this kind of low-resource, code-mixed text. This study builds on that same motivation, constructing its own topic-focused dataset and comparing classical, deep learning, and transformer-based approaches under identical conditions, then extending the strongest model into a deployable, topic-monitoring dashboard. Readers interested in a related deep-learning application to Nigerian-context misinformation may also want to look at ScholarNest's project on fake news detection using deep learning, which tackles a closely related text-classification problem using a comparable benchmarking approach.

Statement of the Problem

Existing sentiment analysis tools and pretrained models are predominantly developed and evaluated on standard English text drawn from Western social media contexts, and consequently perform inconsistently when applied to Nigerian social media discourse, where code-switching, Nigerian Pidgin, informal orthography, and locally specific slang and hashtags are pervasive. Organisations and researchers seeking to understand Nigerian public opinion on social, political, or economic issues therefore lack a readily available, reasonably accurate, and locally relevant sentiment analysis tool, and must either rely on generic sentiment APIs of uncertain accuracy on Nigerian text, or resort to slow, subjective, and unscalable manual reading of posts.

While recent research efforts such as NaijaSenti have produced valuable annotated datasets for Nigerian languages, comparatively few studies combine such resources with a full, benchmarked comparison of classical, deep learning, and transformer-based modelling approaches on a single, purpose-collected, topic-focused dataset, and fewer still extend this work into a deployable, topic-monitoring dashboard that a non-technical user could operate directly. This study addresses that gap.

Aim and Objectives of the Study

The aim of this study is to design, implement, and evaluate a natural language processing pipeline for sentiment analysis of Nigerian social media discourse, and to deploy the resulting model through a topic-monitoring web dashboard.

The specific objectives of the study are to:

●        review existing literature and systems relevant to sentiment analysis, with particular attention to work on Nigerian and African low-resource languages;

●        collect a dataset of Nigerian social media posts spanning several prominent discourse topics, and manually annotate the dataset for sentiment;

●        design a preprocessing pipeline that appropriately handles code-mixed English/Nigerian Pidgin text, hashtags, mentions, and emojis;

●        train and compare classical machine learning models (Naive Bayes, SVM), a BiLSTM deep learning model, and a fine-tuned multilingual transformer (mBERT) model for sentiment classification;

●        conduct error analysis to identify the specific linguistic patterns associated with model misclassification; and

●        implement and evaluate a web-based dashboard that allows a user to monitor aggregated sentiment and trends for a chosen topic or hashtag.

Research Questions

●        What NLP techniques and datasets have been applied to sentiment analysis of Nigerian and other African social media discourse in existing literature?

●        What preprocessing steps meaningfully improve sentiment classification accuracy on Nigerian code-mixed social media text?

●        How do classical machine learning models compare with a BiLSTM and a fine-tuned multilingual transformer model in classifying the sentiment of Nigerian social media posts?

●        What linguistic patterns are most associated with sentiment classification errors in this context?

●        What is the response time and practical usefulness of a web-based topic-sentiment monitoring dashboard built around the trained model?

Significance of the Study

This study speaks to several audiences at once. For researchers and civic technologists, it contributes a benchmarked comparison of modelling approaches on a purpose-collected Nigerian discourse dataset, adding to the still-limited body of empirical work on NLP for Nigerian social media text. For businesses and brand managers, a locally attuned sentiment analysis tool offers more reliable insight into Nigerian consumer opinion than generic, English-centric sentiment APIs. For policy researchers and journalists, the topic-monitoring dashboard offers a practical way to track public sentiment on emerging policy issues, such as fuel subsidy reform or currency policy, as they unfold. For the broader NLP community, the study's error analysis of code-mixed and Nigerian Pidgin misclassifications adds empirical evidence to ongoing efforts to improve NLP support for African languages. The same questions of public trust and opinion formation that this study tracks through sentiment also run through governance research more broadly, including ScholarNest's project on the impact of good governance on national development in Nigeria, where public perception plays a comparable role in shaping outcomes.

Scope of the Study

This study is limited to sentiment classification (positive, negative, neutral) of Nigerian-origin social media posts collected from X, covering three prominent discourse topics selected for their public salience during the data collection period: the 2023 Nigerian general election, the removal of the fuel subsidy, and the Naira redesign policy. The study covers the complete pipeline, from data collection and annotation, through preprocessing, model training, and evaluation, to the implementation of a web-based topic-monitoring dashboard and system-level testing. It does not extend to sentiment analysis of indigenous-language-only text (Hausa, Igbo, or Yoruba without English/Pidgin code-mixing), aspect-based sentiment analysis, sarcasm or irony detection as a distinct task, or large-scale real-time streaming ingestion, although these are identified as directions for further work.

Operational Definition of Terms

Sentiment Analysis — The automated process of determining whether a piece of text expresses a positive, negative, or neutral attitude toward a subject.

Natural Language Processing (NLP) — A field of artificial intelligence concerned with enabling computers to process, analyse, and generate human language.

Code-Switching / Code-Mixing — The practice of alternating between two or more languages or language varieties (e.g., English and Nigerian Pidgin) within a single utterance or conversation.

Nigerian Pidgin — An English-lexified creole language widely spoken across Nigeria, distinct in grammar and vocabulary from Standard English.

Transformer Model — A deep learning architecture based on self-attention mechanisms, widely used as the basis for modern pretrained language models such as multilingual BERT (mBERT), which extends the same architecture across more than 100 languages simultaneously.

Fine-Tuning — The process of further training a pretrained language model on a smaller, task-specific labelled dataset.

Inter-Annotator Agreement — A measure of the degree of consistency between independent human annotators labelling the same data.

Conclusion

Sentiment analysis on Nigerian social media text is genuinely harder than the standard English benchmark case, and this study's results reflect that honestly: strong overall accuracy from the fine-tuned multilingual transformer, alongside a clear, well-documented weak spot around Nigerian Pidgin and code-mixed content. That combination of rigorous benchmarking, a real annotated dataset, and a working topic-monitoring dashboard is exactly the kind of structure that turns a good project idea into a complete, defensible piece of research. If you are shaping a related final-year project and want hands-on support getting from topic to submission, ScholarNest's research and project writing support team can help at any stage of the process.

Frequently Asked Questions

1. What is sentiment analysis of Nigerian social media discourse?

It is the use of NLP techniques to automatically classify Nigerian social media posts, such as tweets on X, as expressing positive, negative, or neutral sentiment toward a given topic.

2. Why is sentiment analysis harder on Nigerian social media text than on standard English text?

Nigerian posts frequently code-switch between English, Nigerian Pidgin, and indigenous languages like Hausa, Igbo, and Yoruba, and make heavy use of informal spelling, slang, hashtags, and emojis, all of which standard English-trained models struggle with.

3. What is mBERT and why is it useful for this task?

mBERT is a multilingual version of BERT pretrained on text from over 100 languages, which allows it to capture contextual patterns across the mix of English and Nigerian language varieties found in code-mixed social media posts.

4. What datasets exist for Nigerian and African language sentiment analysis?

NaijaSenti and AfriSenti are widely cited efforts that provide human-annotated Twitter sentiment corpora for Nigerian languages (Hausa, Igbo, Nigerian Pidgin, Yorùbá) and other African languages, supporting research on low-resource sentiment analysis.

5. Which class of posts is hardest for these models to classify correctly?

Neutral posts and tweets with heavy Nigerian Pidgin or code-mixed content tend to produce the most classification errors, reflecting the broader low-resource status of these language varieties in NLP research.

6. What topics were used to build the dataset in this study?

The dataset was built around three discourse topics with high public salience in Nigeria: the 2023 general election, the removal of the fuel subsidy, and the Naira redesign policy.

7. How is the sentiment model evaluated for accuracy?

The model is evaluated using standard classification metrics such as overall accuracy and macro-averaged F1-score, calculated against a manually annotated test set labelled through a majority-vote scheme across multiple annotators.

8. Is this a good final-year project topic for computer science or NLP-focused students?

Yes. It combines dataset collection and annotation, code-mixed text preprocessing, multiple model architectures, error analysis, and a deployable dashboard, giving students a well-rounded, practically grounded NLP project.

9. What tools are typically used to deploy a sentiment monitoring dashboard?

A common approach is to fine-tune a transformer model such as mBERT and serve it behind a lightweight web framework like Flask, allowing users to submit a topic or hashtag and view an aggregated sentiment breakdown and trend chart.

10. How fast can a deployed sentiment analysis model process social media posts?

With an efficient pipeline, average inference time can be well under half a second per post even on a standard CPU-based server, making near-real-time topic monitoring practical

Purchase to unlock the full material.