News-Based Political Sentiment Analysis for Election Outcome Verification: A BERT-Based Study of the 2024 UK General Election

§ University of Kelaniya
Sri Lanka Institute of Information Technology

Send Message

To: Author

News-Based Political Sentiment Analysis for Election Outcome Verification: A BERT-Based Study of the 2024 UK General Election

Article Fingerprint

ReserarchID

CSTLU6Y5

News-Based Political Sentiment Analysis for Election Outcome Verification: A BERT-Based Study of the 2024 UK General Election Banner

AI TAKEAWAY

Connecting with the Eternal Ground
  • English
  • Afrikaans
  • Albanian
  • Amharic
  • Arabic
  • Armenian
  • Azerbaijani
  • Basque
  • Belarusian
  • Bengali
  • Bosnian
  • Bulgarian
  • Catalan
  • Cebuano
  • Chichewa
  • Chinese (Simplified)
  • Chinese (Traditional)
  • Corsican
  • Croatian
  • Czech
  • Danish
  • Dutch
  • Esperanto
  • Estonian
  • Filipino
  • Finnish
  • French
  • Frisian
  • Galician
  • Georgian
  • German
  • Greek
  • Gujarati
  • Haitian Creole
  • Hausa
  • Hawaiian
  • Hebrew
  • Hindi
  • Hmong
  • Hungarian
  • Icelandic
  • Igbo
  • Indonesian
  • Irish
  • Italian
  • Japanese
  • Javanese
  • Kannada
  • Kazakh
  • Khmer
  • Korean
  • Kurdish (Kurmanji)
  • Kyrgyz
  • Lao
  • Latin
  • Latvian
  • Lithuanian
  • Luxembourgish
  • Macedonian
  • Malagasy
  • Malay
  • Malayalam
  • Maltese
  • Maori
  • Marathi
  • Mongolian
  • Myanmar (Burmese)
  • Nepali
  • Norwegian
  • Pashto
  • Persian
  • Polish
  • Portuguese
  • Punjabi
  • Romanian
  • Russian
  • Samoan
  • Scots Gaelic
  • Serbian
  • Sesotho
  • Shona
  • Sindhi
  • Sinhala
  • Slovak
  • Slovenian
  • Somali
  • Spanish
  • Sundanese
  • Swahili
  • Swedish
  • Tajik
  • Tamil
  • Telugu
  • Thai
  • Turkish
  • Ukrainian
  • Urdu
  • Uzbek
  • Vietnamese
  • Welsh
  • Xhosa
  • Yiddish
  • Yoruba
  • Zulu
Font Type
Font Size
Font Size
Bedground

Abstract

Accurate verification of general election outcomes is essential for understanding political dynamics and democratic processes. However, traditional forecasting methods such as opinion polls and voter surveys often suffer from sampling bias, delayed responses, and limited ability to capture rapid sentiment shifts. This study aims to propose and evaluate a transformer-based political sentiment analysis framework using online news articles to verify the outcome of the 2024 United Kingdom General Election. A dataset of 2,299 online news articles published between January and July 2024 was collected from seven major UK news outlets. A semi-supervised labelling approach was applied to assign sentiment polarity toward the Conservative Party and the Labour Party. To handle long-form political texts exceeding transformer token limits, articles were summarised before being processed. A fine-tuned BERT-base (uncased) model was trained to classify sentiment into positive, neutral, and negative categories. Model performance was assessed using accuracy, precision, recall, and F1-score, while temporal sentiment aggregation was conducted to compare predicted trends with the actual election outcome. The fine-tuned BERT model achieved strong sentiment classification performance, demonstrating robustness in identifying political sentiment from structured news media. Temporal analysis revealed a predominance of negative sentiment toward the Conservative Party, while the Labour Party received significantly higher levels of positive sentiment, particularly in the weeks leading up to the election. These aggregated sentiment trends successfully aligned with and verified the actual election outcome. The findings confirm that online news articles are a reliable alternative data source for political sentiment analysis and election outcome verification. Additionally, the study demonstrates the effectiveness of domain-adapted transformer-based models, such as BERT, in capturing meaningful sentiment shifts that reflect real-world electoral results.

Introduction

Accurate analysis and verification of general election outcomes are essential for understanding political dynamics, public opinion, and democratic decision-making processes. Traditionally, election forecasting has relied on opinion polls, voter surveys, and demographic or economic indicators. Although these approaches have been widely used, their reliability has increasingly been questioned due to issues such as sampling bias, social desirability effects, declining survey response rates, and an inability to capture rapid shifts in voter sentiment close to election dates (Levene & Fenner, 2021; Stegmaier et al., 2023). These limitations have motivated researchers to explore computational and data-driven alternatives for political analysis.

With the proliferation of digital media, sentiment analysis has emerged as a prominent technique for examining political discourse and predicting election outcomes. A substantial body of research has focused on analysing sentiment expressed on social media platforms particularly Twitter (now X) owing to the availability of large volumes of user-generated content and real-time access to political discussions (Burnap et al., 2016; Khan et al., 2021). Several studies have reported correlations between aggregated social media sentiment and electoral performance. However, the effectiveness of social media–based approaches remains constrained by demographic and geographic biases, platform-specific behavioural patterns, and the prevalence of sarcasm, humour, and informal language that challenge accurate sentiment classification (Brito et al., 2024; Ceron et al., 2015). In addition, recent changes to platform policies and restricted API access have raised concerns regarding the reproducibility and long-term viability of election prediction models that rely exclusively on social media data.

In contrast, online news articles represent a comparatively underexplored yet valuable source of political text. News media provides structured, longer-form content with richer contextual information, allowing sentiment to be conveyed through framing, emphasis, and narrative construction rather than explicit opinion alone. Media coverage plays a central role in shaping political perceptions and influencing voter attitudes, making news sentiment a meaningful proxy for understanding the broader political climate (Stromer-Galley, 2014). Despite these advantages, relatively few election-related sentiment analysis studies have systematically utilised online news articles as the primary data source, particularly within the context of the United Kingdom.

Another notable limitation in existing election prediction research lies in model selection. Traditional machine learning classifiers such as Naïve Bayes, Support Vector Machines, Logistic Regression, and Random Forests have been widely applied due to their computational efficiency and interpretability. However, these models rely heavily on handcrafted features and struggle to capture complex contextual relationships in political language (Alvi et al., 2023). Recent advances in deep learning have introduced transformer-based architectures that significantly improve contextual understanding. Among these, Bidirectional Encoder Representations from Transformers (BERT) has achieved state-of-the-art performance across numerous Natural Language Processing (NLP) tasks, including sentiment analysis, by leveraging bidirectional self-attention mechanisms (Devlin et al., 2019; Islam & Zhang, 2024). While BERT and related transformer models have been applied to political text analysis, most studies rely on generic pre-trained models without domain-specific adaptation, limiting their effectiveness in capturing election-specific rhetoric and media framing.

The 2024 United Kingdom General Election provides a compelling case study for addressing these research gaps. Conducted following a prolonged period of single-party governance and amid heightened political scrutiny, the election generated extensive and diverse media coverage across multiple news outlets. Despite the significance of this event, there is a scarcity of UK-focused election prediction studies that employ advanced NLP techniques and non-social-media data sources. This highlights the need for research that integrates domain-adapted transformer models with structured political news content to better understand and verify electoral outcomes.

Motivated by these observations, this study proposes a sentiment analysis framework based on online news articles to verify the outcome of the 2024 UK General Election. The study employs a BERT-base model fine-tuned on domain-specific political news data to classify sentiment toward the two major political parties in the United Kingdom: the Conservative Party and the Labour Party. By aggregating sentiment scores over a six-month pre-election period and analysing temporal sentiment trends, the proposed approach evaluates whether media sentiment aligns with the actual election outcome. In doing so, the study contributes empirical evidence on the viability of news-based sentiment analysis and the effectiveness of domain-adapted transformer models for political outcome verification.

The contributions of this paper are threefold. First, it demonstrates the effectiveness of online news articles as an alternative and complementary data source to social media for election sentiment analysis. Second, it applies domain-specific fine-tuning of a BERT-base model to political news content, addressing limitations associated with generic pre-trained models. Third, it provides an empirical verification of the 2024 UK General Election outcome using aggregated sentiment analysis, contributing to the growing body of research on computational political forecasting.

The remainder of this paper is organised as follows. Section [related-work] reviews related work on election prediction, sentiment analysis, and transformer-based NLP models. Section [methodology] describes the research methodology, including data collection, preprocessing, and sentiment labelling. Section [implementation-and-experimental-setup] presents the implementation details and experimental setup. Section [results-and-discussion] discusses the results and evaluates the model’s performance. Finally, Section [conclusion-and-future-work] concludes the paper and outlines directions for future research.

Research on election outcome analysis has evolved from traditional polling-based approaches to computational methods that leverage large-scale textual data and machine learning techniques. This section reviews prior work across four key areas: traditional election forecasting methods, sentiment analysis–based election studies, deep learning approaches for political text analysis, and the use of transformer-based models in election-related Natural Language Processing (NLP).

Traditional Election Forecasting Methods

Early election prediction research primarily relied on opinion polls, voter surveys, and macroeconomic indicators. Statistical and econometric models were commonly used to forecast election outcomes by analysing historical voting behaviour, approval ratings, and economic performance. While these approaches offered interpretability and theoretical grounding, their predictive accuracy has increasingly been questioned due to sampling bias, non-response bias, and social desirability effects (Stegmaier et al., 2023).

In the UK context, polling-based forecasts have historically played a dominant role in election analysis. However, recent elections have demonstrated notable discrepancies between predicted and actual outcomes, highlighting the limitations of traditional polling methods in capturing late-stage shifts in voter sentiment (Levene & Fenner, 2021). These shortcomings have motivated researchers to explore alternative data-driven techniques capable of incorporating real-time political information.

Sentiment Analysis in Election Studies

The widespread adoption of digital communication platforms has led to increased interest in sentiment analysis as a tool for political forecasting. A substantial proportion of election-related sentiment studies rely on social media data, particularly Twitter (now X), due to its real-time availability and high volume of political discourse. Prior studies have demonstrated that aggregated sentiment extracted from tweets can correlate with election outcomes under certain conditions (Burnap et al., 2016; Ceron et al., 2015).

Despite their popularity, social media–based approaches exhibit several well-documented limitations. Twitter users do not represent the broader electorate, leading to demographic and geographic bias (Khan et al., 2021). Political content on social media frequently includes sarcasm, humour, slang, and coded language, which complicates accurate sentiment classification. Additionally, evolving platform policies, restricted API access, and moderation practices pose challenges for data reliability and reproducibility (Brito et al., 2024). As a result, scholars have cautioned against relying solely on social media sentiment for election prediction.

In contrast, online news articles provide structured, long-form political content with richer contextual information. News media plays a central role in shaping political narratives and influencing public opinion through framing and agenda-setting mechanisms (Stromer-Galley, 2014). While some studies have incorporated news data into political analysis, the majority of election sentiment research continues to prioritise social media sources, leaving the potential of news-based sentiment analysis relatively underexplored—particularly for UK general elections.

Machine Learning and Deep Learning for Political Text Analysis

Traditional machine learning classifiers such as Naïve Bayes, Support Vector Machines, Logistic Regression, and Random Forests have been widely applied to sentiment analysis tasks in political contexts. These models are computationally efficient and perform adequately on smaller datasets; however, they rely heavily on handcrafted features and struggle to capture complex linguistic and contextual relationships inherent in political discourse (Alvi et al., 2023).

To overcome these limitations, researchers have increasingly explored deep learning architectures for sentiment analysis. Models such as Convolutional Neural Networks (CNNs), Recurrent Neural Networks (RNNs), and Long Short-Term Memory (LSTM) networks have demonstrated improved performance by learning distributed text representations. Bidirectional LSTM (BiLSTM) models, in particular, have shown superior performance in election-related sentiment tasks due to their ability to capture contextual dependencies in both forward and backward directions (Agrawal et al., 2020; J et al., 2024). Nevertheless, these sequence-based models face challenges when handling long-range dependencies and longer textual documents, such as news articles.

Transformer-Based Models in Election Sentiment Analysis

Transformer-based architectures represent a significant advancement in NLP by introducing self-attention mechanisms that enable models to capture global contextual relationships within text. Among these models, Bidirectional Encoder Representations from Transformers (BERT) has achieved state-of-the-art results across a wide range of NLP tasks, including sentiment analysis and text classification (Devlin et al., 2019). BERT’s bidirectional attention mechanism allows it to consider both preceding and following context simultaneously, making it particularly effective for analysing nuanced political language.

Several recent studies have applied BERT and related transformer models, such as RoBERTa and DistilBERT, to political sentiment analysis and election prediction. These studies report improved performance compared to traditional machine learning and sequence-based deep learning models (Chandra, 2021; Feng et al., 2023). However, most existing work relies on generic pre-trained transformer models without domain-specific fine-tuning. This limits the model’s ability to capture election-specific terminology, party rhetoric, and media framing effects.

Furthermore, transformer models impose input token length constraints, which complicate their application to long-form news articles unless appropriate preprocessing strategies such as summarisation or text segmentation—are employed (Islam & Zhang, 2024). Despite these challenges, domain-adapted transformer models remain underutilised in election prediction research, particularly within the UK political context.

Research Gaps

Although sentiment analysis has become an established approach in election studies, several gaps remain. First, there is an overreliance on social media data, with limited exploration of alternative sources such as online news articles. Second, despite the demonstrated effectiveness of transformer-based models, their use in election prediction remains relatively limited compared to traditional machine learning techniques. Third, there is a lack of UK-focused election studies that employ advanced NLP models and non-social-media data sources.

Addressing these gaps, the present study utilises online news articles as the primary data source and applies a domain-specific fine-tuned BERT model to analyse sentiment related to the 2024 UK General Election. By integrating structured political news content with advanced transformer-based sentiment analysis, this study contributes to the growing literature on computational political forecasting and offers new insights into election outcome verification.

Methodology

This study adopts an applied Natural Language Processing (NLP)–based research design to verify the outcome of the 2024 United Kingdom General Election using sentiment analysis of online news articles. The methodology integrates data collection from reputable news sources, systematic text preprocessing, sentiment labelling, and transformer-based model training and evaluation. The overall workflow is designed to ensure reproducibility, robustness, and alignment with best practices in computational political analysis.

Research Design

The research follows a quantitative, data-driven design grounded in machine learning and NLP techniques. Although the source data consists of unstructured textual content, the study operationalises sentiment polarity as categorical variables (positive, negative, neutral), enabling quantitative analysis and model evaluation. The study is classified as applied research, as it utilises established deep learning architectures to address a real-world problem—verifying election outcomes using media sentiment.

Given the absence of pre-labelled political news datasets specific to UK elections, the study employs a semi-supervised approach, combining automated sentiment labelling with manual validation to construct a high-quality training corpus (Alammar, 2021).

Data Sources and Collection

Online news articles were selected as the primary data source due to their structured language, editorial oversight, and influential role in shaping political narratives. Articles were collected from seven widely read and reputable UK-based news outlets: BBC, Sky News, The Sun, The Guardian, The Independent, Daily Mail, and The Mirror. These outlets collectively represent a broad spectrum of political perspectives and readership demographics.

News Source
Articles
Articles
Articles
BBC5564119
Sky News5852110
The Sun263157
The Guardian9657851,750
The Independent474390
Daily Mail423678
The Mirror504595
Total1,2431,0562,299

Summary of News Article Data Set

This table summarises the final dataset after preprocessing and cleaning. Articles were collected from seven major UK online news outlets between January 4 and July 4, 2024. Each article was categorised based on relevance to the Conservative Party and/or the Labour Party. The dataset shows a near-balanced distribution of political coverage across the two major parties.

The data collection period spanned 4 January 2024 to 4 July 2024, covering the six months leading up to the general election. Articles were retrieved using a combination of manual extraction and application programming interfaces (APIs), depending on data availability. Keyword-based search strategies were employed to identify election-related content, including terms associated with the election event, political parties, and party leaders (e.g., UK General Election 2024, Conservative Party, Labour Party, Rishi Sunak, Keir Starmer).

Each collected article included metadata such as publisher, publication date, headline, article body, and URL. Following preprocessing and filtering, the final dataset comprised 2,299 news articles, with a near-balanced distribution between Conservative Party–focused and Labour Party–focused coverage.

Data Preprocessing

To ensure data quality and compatibility with transformer-based models, several preprocessing steps were applied. Duplicate articles and entries with missing content were removed. Non-political articles retrieved due to keyword overlap were manually filtered out based on section metadata and content relevance.

For sentiment analysis, article headlines and body text were concatenated to form a single textual input per article. Text normalisation steps included lowercasing, removal of extraneous whitespace, and elimination of irrelevant artefacts such as embedded hyperlinks or advertisements. No aggressive stop-word removal or stemming was applied, as transformer models rely on contextual token representations and benefit from preserving original linguistic structure.

Due to the maximum input length constraint of transformer models, articles exceeding the token limit were summarised to approximately 350 words prior to model input. This approach ensured retention of core semantic content while remaining within computational limits (Islam & Zhang, 2024).

Sentiment Labelling Strategy

Sentiment labelling was conducted to classify political sentiment toward the two major UK political parties: the Conservative Party and the Labour Party. Each article was assigned two sentiment labels, one for each party, recognising that political news articles often discuss multiple parties within a single narrative.

An automated labelling approach was implemented using a large language model–based annotation process, guided by structured prompts to ensure consistent output formatting. Sentiment labels were categorised as positive, negative, or neutral for each party. To enhance reliability, a subset of labelled articles was manually reviewed and corrected where necessary, particularly in cases involving cross-party criticism or comparative framing.

This dual-labelling strategy enabled fine-grained sentiment analysis and avoided oversimplified assumptions that an article’s overall tone applies uniformly to all political actors mentioned.

Model Selection and Training

The study employs BERT-base (uncased) as the primary sentiment classification model. BERT was selected due to its bidirectional contextual understanding, strong performance in sentiment analysis tasks, and suitability for medium-sized datasets (Devlin et al., 2019). Compared to larger transformer variants, BERT-base offers a favourable balance between model capacity and computational efficiency.

The labelled dataset was partitioned into training and testing subsets using an 80:20 split. Fine-tuning was performed on the training set, with model parameters optimised for multi-class sentiment classification. Standard optimisation techniques were applied, including learning rate scheduling and batch-based gradient descent. Model training was conducted using GPU acceleration to ensure computational feasibility.

Evaluation Metrics

Model performance was evaluated using four widely adopted classification metrics: accuracy, precision, recall, and F1-score. These metrics provide complementary insights into overall performance, class-level balance, and error distribution, which are particularly important in sentiment classification tasks involving potential class imbalance.

Beyond standard classification evaluation, aggregated sentiment scores were computed across the full dataset and analysed temporally to verify alignment between predicted sentiment trends and the actual election outcome. This aggregation-based evaluation enabled validation of the model’s effectiveness at the macro-political level, rather than solely at the individual document level.

Workflow of the Proposed Election Sentiment Analysis Framework
Figure 1. Workflow of the Proposed Election Sentiment Analysis Framework

Figure 1 illustrates the end-to-end workflow of the proposed framework, including data collection, preprocessing, sentiment labelling, BERT fine-tuning, and election outcome verification.

Implementation and Experimental Setup

This section describes the technical implementation of the proposed sentiment analysis framework, including the experimental environment, model configuration, training procedure, and sentiment aggregation strategy used to verify the 2024 UK General Election outcome. The implementation was designed to balance methodological rigor with practical computational constraints.

Experimental Environment

All experiments were implemented using the Python programming language and standard NLP and deep learning libraries. Transformer-based model training and fine-tuning were conducted using the Hugging Face Transformers framework, which provides pre-trained language models and utilities for transfer learning. Due to the computational requirements of transformer models, experiments were executed in a GPU-enabled environment to ensure feasible training times.

The implementation environment consisted of:

  • Python-based deep learning stack

  • Transformer models accessed via the Hugging Face library

  • GPU acceleration for model fine-tuning and inference

This configuration enabled efficient experimentation while maintaining reproducibility across different computing platforms.

Model Architecture

The core sentiment classification model used in this study is BERT-base (uncased), which consists of 12 transformer encoder layers, 12 self-attention heads, and a hidden size of 768 dimensions. The model was selected due to its strong performance in sentiment analysis tasks and its suitability for medium-sized datasets under limited computational resources.

A classification head was added to the final hidden layer of BERT to perform multi-class sentiment classification. The output layer employed a softmax activation function to predict sentiment labels across three categories: positive, neutral, and negative. Separate classification outputs were produced for sentiment toward the Conservative Party and the Labour Party.

Input Representation and Tokenisation

Each news article was represented as a single textual input by concatenating the headline and article body. Prior to model ingestion, text inputs were tokenised using BERT’s WordPiece tokeniser. Special tokens [CLS] and [SEP] were automatically inserted to denote sequence boundaries, following standard BERT input conventions.

Given BERT’s maximum input length constraint of 512 tokens, articles exceeding this limit were summarised to approximately 350 words prior to tokenisation. This strategy ensured that the core semantic content of each article was retained while avoiding truncation that could lead to loss of contextual information. Padding and attention masks were applied to ensure uniform input length during batch processing.

Training Configuration

The sentiment-labelled dataset was divided into training and testing subsets using an 80:20 split, ensuring that the test set remained unseen during model training. Fine-tuning was performed by updating all BERT parameters along with the classification head.

Key training hyperparameters were configured as follows:

  • Batch size: 16

  • Learning rate: 2 × 10 5

  • Optimizer: AdamW

  • Number of epochs: 3–5 (with early stopping based on validation performance)

  • Loss function: Cross-entropy loss

These values were selected based on widely accepted best practices for fine-tuning transformer models on text classification tasks. Early stopping was employed to mitigate overfitting and ensure model generalisation.

Handling Class Imbalance

Preliminary analysis of the labelled dataset indicated a degree of class imbalance, particularly for positive sentiment toward the Conservative Party. To address this issue, class-weighted loss functions were applied during training, assigning higher weights to underrepresented sentiment classes. This approach helped prevent model bias toward majority classes and improved balanced classification performance.

Evaluation Procedure

Model performance was evaluated on the held-out test set using four standard classification metrics: accuracy, precision, recall, and F1-score. These metrics were computed for each sentiment class and averaged using macro-averaging to account for class imbalance.

In addition to document-level evaluation, the model’s effectiveness was assessed at an aggregate level by analysing sentiment trends across time and political parties. This dual evaluation strategy ensured that the model performed well both as a text classifier and as a tool for macro-level political analysis.

Sentiment Aggregation and Election Outcome Verification

To verify the election outcome, predicted sentiment labels were aggregated across all articles for each political party over the six-month pre-election period. Aggregate sentiment scores were computed by counting the number of positive, neutral, and negative articles associated with each party and analysing their temporal distribution.

The winning party was inferred based on overall sentiment dominance, with particular emphasis on the balance between positive and negative sentiment in the weeks leading up to the election. These aggregated predictions were then compared with the official election results to assess the alignment between media sentiment and the actual electoral outcome.

Results and Discussion

This section presents the empirical results obtained from the proposed BERT-based sentiment analysis framework and discusses their implications for verifying the 2024 United Kingdom General Election outcome. The analysis is conducted at two levels: (1) document-level sentiment classification performance and (2) aggregate sentiment trends used for election outcome verification.

Sentiment Classification Performance

The fine-tuned BERT-base model demonstrated strong performance in classifying sentiment across the three categories positive, neutral, and negative for both political parties. Evaluation on the held-out test set showed that the model achieved consistently high F1-scores, indicating a balanced trade-off between precision and recall across sentiment classes.

The use of class-weighted loss functions contributed to improved recognition of underrepresented sentiment categories, particularly positive sentiment toward the Conservative Party. Compared to baseline expectations reported in prior election sentiment studies that rely on traditional machine learning classifiers, the transformer-based approach exhibited superior robustness in handling nuanced political language and contextual framing.

Overall, the results confirm that domain-adapted transformer models are well-suited for sentiment analysis tasks involving structured political news content, where subtle linguistic cues and long-range contextual dependencies play a critical role.

Distribution of Political Sentiment

Analysis of the full dataset revealed a clear asymmetry in sentiment distribution between the two major political parties. A substantial proportion of news articles expressed negative sentiment toward the Conservative Party, whereas positive sentiment toward the Labour Party was considerably more prevalent. Neutral sentiment was observed for both parties but appeared more evenly distributed as shown in Figure [fig:sentiment-dist].

Distribution of Sentiment Towards Major Political Parties
Figure 2. Distribution of Sentiment Towards Major Political Parties

The presence of dual sentiment labels per article enabled a more granular analysis, capturing cases where an article expressed contrasting sentiment toward different parties. This dual-labelling approach reduced oversimplification and provided a more accurate representation of political discourse, particularly in comparative or adversarial reporting.

These findings suggest that online news sentiment reflects broader political narratives and media framing tendencies rather than isolated opinions, reinforcing the suitability of news articles as a meaningful source for election-related sentiment analysis.

Temporal analysis of sentiment trends over the six-month pre-election period revealed notable shifts in media sentiment as the election date approached. Negative sentiment toward the Conservative Party showed a consistent upward trajectory, particularly in the final weeks of the campaign. In contrast, positive sentiment toward the Labour Party increased steadily, accompanied by a relative decline in negative coverage.

These temporal patterns align with major political developments and campaign dynamics observed during the election period. The ability of the model to capture such trends demonstrates its effectiveness in tracking sentiment evolution over time, which is critical for election outcome verification as shown in Figure [fig:temporal-trends].

Temporal Trends of Political Sentiment Prior to the 2024 UK General Election
Figure 3. Temporal Trends of Political Sentiment Prior to the 2024 UK General Election

Importantly, sentiment polarity in the immediate pre-election period proved to be more indicative of the final outcome than sentiment aggregated uniformly across the entire data collection window. This observation supports prior findings that late-stage sentiment dynamics play a decisive role in electoral behaviour.

Election Outcome Verification

To verify the election outcome, sentiment predictions were aggregated across all articles for each political party. The aggregate sentiment profile indicated a clear dominance of positive sentiment for the Labour Party and a predominance of negative sentiment for the Conservative Party. Based on this sentiment imbalance, the proposed framework correctly inferred the Labour Party as the election winner.

This result demonstrates that sentiment extracted from online news articles when analysed using a domain-adapted transformer model can effectively reflect real-world electoral outcomes. Unlike traditional polling or social media–based approaches, the proposed method relies on structured, context-rich media content, reducing susceptibility to demographic bias and informal language distortions.

Discussion

The findings of this study highlight several important insights. First, the strong performance of the BERT-based model confirms the advantages of transformer architectures in analysing complex political language, particularly in long-form news articles. The bidirectional attention mechanism enables the model to capture nuanced sentiment expressions that are often missed by traditional machine learning and sequence-based deep learning models.

Second, the use of online news articles as the primary data source proved effective for election outcome verification. News media sentiment captures not only explicit opinions but also framing, emphasis, and narrative tone, which collectively influence public perception. This suggests that news-based sentiment analysis can serve as a valuable complement or alternative to social media–centric election studies.

Third, domain-specific fine-tuning played a crucial role in enhancing model performance. By adapting BERT to political news content related to the UK election, the model was better equipped to interpret election-specific terminology, party rhetoric, and contextual cues. This finding addresses a key gap in existing literature, where generic pre-trained models are often applied without domain adaptation.

Despite these strengths, the study has limitations. Media sentiment does not equate directly to voter sentiment, and editorial biases may influence coverage patterns. Additionally, summarisation of long articles—while necessary due to token constraints may result in partial information loss. Future research could explore transformer models designed for longer documents or hybrid approaches combining news and social media data.

Conclusion and Future Work

This study investigated the viability of using online news articles and transformer-based sentiment analysis to verify the outcome of the 2024 United Kingdom General Election. By leveraging a domain-adapted BERT-base model, the research demonstrated that sentiment extracted from structured political news content can effectively reflect real-world electoral outcomes. The proposed framework successfully captured sentiment polarity toward the two major political parties and correctly inferred the election winner through aggregate sentiment analysis.

The results provide empirical evidence that online news media constitutes a meaningful and underutilised data source for election-related sentiment analysis. Unlike social media platforms, news articles offer richer contextual information and more formal language, enabling deeper semantic interpretation through advanced NLP models. The strong performance of the fine-tuned BERT model highlights the advantages of transformer architectures in analysing complex political discourse, particularly when domain-specific adaptation is applied.

From a methodological perspective, the study contributes to the literature by demonstrating the effectiveness of a dual-party sentiment labelling strategy and by addressing practical challenges associated with long-form political text, such as token length constraints. The findings further support the argument that domain-adapted transformer models outperform generic pre-trained approaches in political sentiment analysis tasks.

Despite its contributions, this study has several limitations. Media sentiment may not fully represent voter sentiment, as news coverage is influenced by editorial priorities and framing. Additionally, the summarisation of long articles, while necessary for computational feasibility, may result in partial loss of contextual information. The study also focused exclusively on two major political parties, which limits generalisability to multi-party electoral systems.

Future research could extend this work in several directions. First, transformer models designed for long-document processing, such as Longformer or BigBird, could be explored to analyse full-length articles without summarisation. Second, incorporating additional data sources—such as social media, televised debates, or party manifestos—may provide a more holistic view of political sentiment. Third, future studies could examine constituency-level or regional sentiment trends to support granular election forecasting. Finally, applying the proposed framework to elections in other democratic contexts would help assess its generalisability and robustness.

In conclusion, this study demonstrates that combining online news sentiment with domain-adapted transformer models offers a promising and reliable approach for election outcome verification. The findings contribute to the growing body of research on computational political analysis and highlight new opportunities for leveraging advanced NLP techniques in democratic studies.

References

15 Cites in Article
  1. Agrawal,Mittal,Bansal,Garg (2020). Sentiment analysis of Twitter data for predicting election results using LSTM.
  2. Alammar (2021). Illustrated BERT, ELMo, and co.: How NLP cracked transfer learning.
  3. Alvi,Zia,Khalil,Ahmad (2023). A systematic literature review on election prediction using Twitter sentiment analysis.
  4. Brito,Duarte,Ferreira (2024). Challenges and limitations of using Twitter data for political sentiment analysis.
  5. Burnap,Gibson,Sloan,Southern,Williams (2016). 140 characters to victory? Using Twitter to predict the UK 2015 General Election.
  6. Ceron,Curini,Iacus,Porro (2015). Every tweet counts? How sentiment analysis of social media can improve our knowledge of citizens’ political preferences.
  7. Chandra (2021). Election prediction using sentiment analysis and BERT.
  8. Devlin,Chang,Lee,Toutanova (2019). BERT: Pre-training of deep bidirectional transformers for language understanding.
  9. Feng,Sun,Wang,Zhang (2023). Hybrid machine learning and sentiment analysis approach for election prediction.
  10. Islam,Zhang (2024). A comprehensive review of BERT-based language models in natural language processing.
  11. J.,Kumar,Sharma (2024). Deep learning–based sentiment analysis for election prediction using BiLSTM.
  12. Khan,Alvi,Hussain (2021). Sentiment analysis and election prediction on Twitter: A review.
  13. Levene,Fenner (2021). Poll aggregation and election forecasting using stochastic differential equations.
  14. Stegmaier,Lewis-Beck,Jérôme (2023). Election forecasting: The state of the art.
  15. Stromer-Galley (2014). Presidential campaigns in the Internet age.

Funding

No external funding was declared for this work.

Conflict of Interest

The authors declare no conflict of interest.

Ethical Approval

No ethics committee approval was required for this article type.

Data Availability

The data that support the findings of this study are available from the corresponding author.

How to Cite This Article

Dr. Ppg Dinesh Asanka, Kushani Maduhansi Hettiarachchi. 2026. "News-Based Political Sentiment Analysis for Election Outcome Verification: A BERT-Based Study of the 2024 UK General Election". Global Journal of Computer Science and Technology, Global Journal of Computer Science and Technology - D: Neural & AI GJCST-D Volume 26 (GJCST Volume 26 Issue D1).

Download Citation

Journal Specifications

Crossref Journal DOI 10.17406/gjcst

Print ISSN 0975-4350

e-ISSN 0975-4172

Keywords
Classification
ACM I.2.7
arXiv cs.CL
IEEE NLP
LCC JN901
Version of record

v1.2

Issue date
February 17, 2026

Language
English
Experiance in AR

Explore published articles in an immersive Augmented Reality environment. Our platform converts research papers into interactive 3D books, allowing readers to view and interact with content using AR and VR compatible devices.

Read in 3D

Your published article is automatically converted into a realistic 3D book. Flip through pages and read research papers in a more engaging and interactive format.

Article Matrices
Total Views: 163
Total Downloads: 12
All Trends

Request Access

Please fill out the form below to request access to this research paper. Your request will be reviewed by the editorial or author team.
X

This is the heading

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

High-quality academic research articles on global topics and journals.

News-Based Political Sentiment Analysis for Election Outcome Verification: A BERT-Based Study of the 2024 UK General Election

PPG Dinesh Asanka
PPG Dinesh Asanka <p>University of Kelaniya</p>
Kushani Maduhansi Hettiarachchi
Kushani Maduhansi Hettiarachchi Sri Lanka Institute of Information Technology