Generalized Word Shift Graphs: A Method for Visualizing and Explaining Pairwise Comparisons Between Texts

Ryan J. Gallagher, Morgan R. Frank, Lewis Mitchell, Aaron J. Schwartz, Andrew J. Reagan +2 more
8/5/2020
cs.CLcs.CYcs.SI

Official code: ryanjgallagher/shifterator (291 stars, Apache-2.0, last commit 2026-08-27).

Abstract

A common task in computational text analyses is to quantify how two corpora differ according to a measurement like word frequency, sentiment, or information content. However, collapsing the texts' rich stories into a single number is often conceptually perilous, and it is difficult to confidently interpret interesting or unexpected textual patterns without looming concerns about data artifacts or measurement validity. To better capture fine-grained differences between texts, we introduce generalized word shift graphs, visualizations which yield a meaningful and interpretable summary of how individual words contribute to the variation between two texts for any measure that can be formulated as a weighted average. We show that this framework naturally encompasses many of the most commonly used approaches for comparing texts, including relative frequencies, dictionary scores, and entropy-based measures like the Kullback-Leibler and Jensen-Shannon divergences. Through several case studies, we demonstrate how generalized word shift graphs can be flexibly applied across domains for diagnostic investigation, hypothesis generation, and substantive interpretation. By providing a detailed lens into textual shifts between corpora, generalized word shift graphs help computational social scientists, digital humanists, and other text analysis practitioners fashion more robust scientific narratives.

View on arXivView PDF

Code Implementations(1)

Apache-2.0

Interpretable data visualizations for understanding how texts differ at the word level

29132PythonMay 16, 20181 months agoApache-2.0
computational-social-sciencedata-visualizationdigital-humanitiesinformation-theorynatural-language-processing+3 more

Cite this paper

@article{gallagher2020generalized,
  title  = {Generalized Word Shift Graphs: A Method for Visualizing and Explaining Pairwise Comparisons Between Texts},
  author = {Ryan J. Gallagher and Morgan R. Frank and Lewis Mitchell and Aaron J. Schwartz and Andrew J. Reagan and Christopher M. Danforth and Peter Sheridan Dodds},
  year   = {2020},
  eprint = {2008.02250},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2008.02250}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2008.02250.svg)](https://codeofpaper.com/paper/2008.02250)

Discussion