Skip to main content

Text Analytics on U.S. Presidential Inaugural Speeches

Project Overview

In this project, I performed text analytics and natural language processing (NLP) on three historic U.S. Presidential inaugural speeches to understand their linguistic structure, vocabulary usage, and dominant themes.

Speeches Analyzed

  • Franklin D. Roosevelt – 1941

  • John F. Kennedy – 1961

  • Richard Nixon – 1973

The goal was not political analysis, but language analysis using Python and NLP libraries.

Git Link


Problem Definition

The objectives of this analysis were:

  1. Compute text statistics for each speech:

    • Number of characters

    • Number of words

    • Number of sentences

    • Average word length

  2. Perform text preprocessing:

    • Lowercasing

    • Removing punctuation, numbers, and special characters

    • Stopword removal

    • Stemming

  3. Identify the most frequently used words across all three speeches

  4. Visualize dominant themes using a Word Cloud

Data Source

The speeches were sourced from the NLTK Inaugural Corpus, which contains official U.S. presidential inaugural addresses dating back to 1789.

from nltk.corpus import inaugural

An additional Excel file was used to organize the speeches into a structured tabular format.

Exploratory Data Analysis (EDA)

Dataset Structure

ColumnDescription
NamePresident name
SpeechFull speech text
  • Rows: 3

  • Columns: 2

  • Data Type: Text (object)

No missing values or duplicates were found.


Text Statistics – Key Findings

1️⃣ Character Count

  • Nixon’s speech was the longest, exceeding 10,000 characters

  • Roosevelt and Kennedy speeches were similar in length (~7,600 characters)

2️⃣ Word Count

  • Nixon: 1,769 words

  • Kennedy: 1,364 words

  • Roosevelt: 1,323 words

➡️ Indicates a shift toward longer, more detailed addresses over time.

3️⃣ Average Word Length

All speeches had similar average word lengths:

  • Roosevelt: 4.78

  • Kennedy: 4.62

  • Nixon: 4.71

➡️ Suggests consistent linguistic complexity across decades.

4️⃣ Sentence Count

Sentence tokenization revealed:

  • An average of 60–70 sentences per speech

  • Balanced sentence structures with rhetorical emphasis


Text Preprocessing Pipeline

To prepare the text for analysis, the following steps were applied:

✔ Lowercasing

Ensures uniformity (Americaamerica)

✔ Special Character & Number Removal

Removed:

  • Punctuation

  • Line breaks

  • Digits

  • Symbols

✔ Stopword Removal

  • Removed common English stopwords (e.g., the, is, and)

  • Extended stopword list to remove context-specific words like “mr”

✔ Stemming

Applied Porter Stemmer to reduce words to root form:

  • running → run

  • freedom → freedom

This improved frequency analysis consistency.

Frequency Analysis – Most Common Words

After preprocessing, the most frequently occurring words across all speeches were:

RankWord
1new
2world
3america
4peace
5nation
6freedom
7people

Interpretation

  • “America” & “nation” reflect national identity focus

  • “Peace” & “freedom” dominate Cold War–era rhetoric

  • “New” & “world” indicate optimism and global outlook

Rare words were intentionally retained to preserve contextual meaning.


☁️ Word Cloud Visualization

A Word Cloud was generated to visually represent dominant themes across all speeches.

Insights from Word Cloud

  • Large prominence of peace, freedom, democracy, nation

  • Strong emphasis on global responsibility and unity

  • Consistent ideological messaging across different administrations

➡️ Visual analysis complements numerical frequency counts and improves interpretability.


🧠 Key Learnings & Insights

  1. Presidential speeches maintain consistent linguistic complexity

  2. Themes of freedom, peace, and national responsibility dominate across eras

  3. Text preprocessing dramatically improves signal clarity

  4. Word clouds are effective for quick thematic exploration

  5. NLP techniques can extract meaningful insights from unstructured text


🛠️ Skills & Tools Demonstrated

Technical Skills

  • Natural Language Processing (NLP)

  • Text preprocessing & cleaning

  • Tokenization & stemming

  • Frequency analysis

  • Data visualization

Tools & Libraries

  • Python

  • Pandas

  • NLTK

  • Matplotlib

  • WordCloud


Final Recommendation

This project can be extended further by:

  • Sentiment analysis across speeches

  • TF-IDF based keyword extraction

  • Topic modeling (LDA)

  • Speech comparison by political era







Comments

Popular posts from this blog

Power BI Sales & Inventory Forecasting Project (SARIMA)

Project Overview In this project, I built an end-to-end Business Analytics & Data Science solution using SQL, Power BI, and Python to: Analyze historical sales, profit, discounts, and units sold Build an Executive Summary Dashboard for leadership Forecast next 3 months of Sales & Units Sold Support inventory planning and business decision-making This project simulates a real-world eCommerce / Retail analytics use case , combining ETL, BI reporting, and predictive modeling in a single workflow. Business Objective Primary Goals Provide leadership with a single-source executive dashboard Identify sales, profit, and regional performance trends Predict future demand (Sales & Units Sold) for: Inventory planning Revenue forecasting Procurement & supply-chain readiness Key Questions Answered How are sales and profits trending over time? Which regions and segments drive the most value? What will be the expected sales & unit demand for the next 3 months? Architecture ...

Data Analysis and Visualization with Matplotlib and Seaborn | TOP 10 code snippets for practice

Data visualization is an essential aspect of data analysis. It enables us to better understand the underlying patterns, trends, and insights within a dataset. Two of the most popular Python libraries for data visualization are Matplotlib and Seaborn . Both libraries are highly powerful, and they can be used to create a wide variety of plots to help researchers, analysts, and data scientists present data visually. In this article, we will discuss the basics of both libraries, followed by the top 10 most used code snippets for visualization. We'll also provide links to free resources and documentation to help you dive deeper into these libraries. Matplotlib and Seaborn: A Quick Overview Matplotlib Matplotlib is a low-level plotting library in Python. It allows you to create static, animated, and interactive plots. It provides a lot of flexibility but may require more code to create complex plots compared to Seaborn. Matplotlib is especially useful when you need full control ove...

Election Data Classification Project – End-to-End Analysis

Problem Definition The objective of this project is to predict voter preference (Labour vs Conservative) using demographic, economic perception, political leadership ratings, and political awareness variables. This is a binary classification problem , where the target variable is: vote_Labour (1 = Labour, 0 = Conservative) The analysis aims to: Understand data structure and distributions Identify relationships between predictors and voting behavior Build and compare multiple classification models Select the best model based on performance metric Git Link Dataset Overview Rows: 1,525 voters Columns: 9 features + 1 target Data Types: Numerical: Age, economic conditions, leader ratings, political knowledge Categorical: Vote, Gender Missing Values: None Duplicates: 8 (not materially impactful) Target Variable Distribution Labour voters: ~70% Conservative voters: ~30% ➡️ Dataset is moderately imbalanced , which makes recall and AUC important evaluation metrics in addition to accuracy...