Back to Projects

Project case study

ML - NLP · 2026

From Uncertainty to Explanation: Pre- vs Post-Election Discourse (Text-as-Data)

Exploratory NLP pipeline on a 20-text 2024 election corpus comparing pre-election uncertainty framing to post-election explanatory framing using TF–IDF, document similarity, syntactic complexity, and interpretable dictionary-based indices.

Highlights

  • Built a structured corpus (n=20) with metadata (category, outlet, date) and reproducible R pipeline outputs (CSVs + figures).
  • Triangulated lexical distinctiveness (TF–IDF), Pearson correlation similarity, and dependency-parse syntactic complexity to compare pre vs post framing.
  • Added battleground-state mention density + a forecasting-vs-explanation lexical index to quantify narrative shift and control for outlet effects.

Gallery

What

I built a small corpus of election-focused political texts split into pre-election and post-election categories to study how rhetoric changes once uncertainty resolves into known outcomes.

My core question was: how does discourse shift from anticipatory uncertainty to retrospective explanation after results are known?

How

I used TF–IDF to surface what vocabulary was uniquely concentrated in each document and compared pre vs post distinctiveness patterns.

I computed pairwise Pearson correlations over a trimmed document-feature matrix to map similarity structure and identify clustered vs outlier documents.

I ran udpipe dependency parsing on selected pre and post texts and computed reproducible syntactic complexity measures (sentence length, clauses, dependent clauses, coordination, complex nominals).

To make the analysis more directly interpretable, I added (1) battleground-state mention density normalized by document length and (2) a dictionary-based forecasting-vs-explanation index (per-1,000 tokens), plus an outlet-level decomposition to sanity-check outlet effects.

Results

Across methods, I found a consistent pre/post framing shift: pre-election writing leans toward polling/forecast uncertainty and state-specific strategic discussion, while post-election writing leans toward diagnostic explanation (error, bias, turnout, coalition narratives).

The forecasting-vs-explanation index provided an interpretable quantitative signal of the rhetorical shift and the outlet-level breakdown helped separate temporal effects from repeated outlet style.