A comprehensive computational analysis of the September 10, 2024 presidential debate between Vice President Kamala Harris and Former President Donald Trump, hosted by ABC News in Philadelphia.
This project applies natural language processing (NLP) and sentiment analysis techniques to extract insights from the debate transcript, examining:
- Sentiment patterns (polarity and subjectivity) across different topics
- Emotional tone of each candidate's rhetoric
- Topic distribution and focus areas
- Temporal sentiment evolution throughout the debate
- Data Preprocessing: Automated text cleaning and speaker separation using regular expressions
- Topic Classification: Multi-topic categorization including Economy, Immigration, Foreign Policy, Healthcare, Climate Change, and more
- Sentiment Analysis: Polarity and subjectivity scoring using TextBlob
- Emotion Detection: Granular emotion classification using NRCLex
- Sliding Window Analysis: Temporal sentiment tracking across the debate timeline
- Rich Visualizations: Heatmaps, line plots, and distribution charts for comprehensive insights
Source: ABC News Presidential Debate Date: September 10, 2024 Location: National Constitution Center, Philadelphia, PA Moderators: David Muir and Linsey Davis Participants: Vice President Kamala Harris and Former President Donald Trump
The debate transcript (debate_transcript.txt) includes the complete exchange between candidates across multiple policy areas.
- Removal of moderator commentary
- Speaker-specific text extraction
- Sentence-level segmentation
- Keyword-based topic classification
- Polarity: Measures positive vs. negative sentiment (-1 to +1)
- Subjectivity: Measures factual vs. opinionated language (0 to 1)
- Sliding Window: 50-word windows to track sentiment evolution
- Multi-dimensional emotion scoring (anticipation, joy, trust, fear, surprise, sadness, anger, disgust)
- Dominant emotion identification per statement
- Cross-tabulation of emotions by topic and speaker
- Polarity Over Time: Line chart showing sentiment trends throughout the debate
- Subjectivity Over Time: Evolution of objectivity vs. subjectivity in language
- Topic Distribution: Frequency of topics discussed by each candidate
- Dominant Emotions: Comparative emotion profiles between candidates
- Topic-Sentiment Heatmaps: Average polarity and subjectivity by topic and speaker
- Emotion-Topic Heatmap: Distribution of emotions across different discussion topics
- Python 3.7+
- Jupyter Notebook or JupyterLab
Install required packages:
pip install pandas matplotlib seaborn textblob nrclexDownload TextBlob corpora:
python -m textblob.download_corpora- Clone this repository:
git clone https://github.com/aaliusama/US_Presidential_Debates_Analysis.git
cd US_Presidential_Debates_Analysis- Launch Jupyter Notebook:
jupyter notebook- Open
debate_analysis.ipynband run all cells sequentially.
├── debate_analysis.ipynb # Main analysis notebook
├── debate_transcript.txt # Raw debate transcript data
└── README.md # Project documentation
The analysis reveals distinct rhetorical patterns between the two candidates across multiple dimensions:
- Sentiment Patterns: Comparative polarity scores show varying approaches to positive vs. negative framing
- Topic Focus: Clear differences in topic emphasis and distribution
- Emotional Tone: Distinct emotion profiles characterizing each candidate's communication style
- Temporal Dynamics: Evolution of sentiment intensity throughout the debate
For detailed results and visualizations, please refer to the Jupyter notebook.
- Python: Core programming language
- Pandas: Data manipulation and analysis
- TextBlob: Sentiment polarity and subjectivity analysis
- NRCLex: Emotion detection and classification
- Matplotlib & Seaborn: Data visualization
- Regular Expressions: Text preprocessing and pattern matching
- Comparative analysis with previous presidential debates
- Real-time sentiment tracking during live debates
- Topic modeling using LDA or other advanced NLP techniques
- Fact-checking integration
- Audience reaction correlation analysis
This project is available for educational and research purposes.
Ali Usama
- ABC News for the debate transcript
- TextBlob and NRCLex development teams for their excellent NLP libraries