Wordcloud of the Arizona et al. v. United States opinion

Archive · 1 min read

Here's one purely for fun - a wordcloud built from the Supreme Court's opinion on Arizona et al. v United States (tile.loc.gov/storage-services/service/ll/usrep/usrep567/u...). Word clouds, though certainly not the most scientific of visualization techniques, are often engaging and "fun" ways to lead into discussion on NLP or topic modeling.

Arizona et al. v United States wordcloud
Arizona et al. v United States wordcloud

The process to generate this image is entirely automated with Tika (tika.apache.org/) and R (www.r-project.org/). We convert the PDF to text, strip, normalize, and stopword the text, then convert to histogram and plot as a wordcloud. Here's the snippet below:

$ java -jar /opt/tika/tika.jar --text arizona_et_al_v_united_states.pdf >  arizona_et_al_v_united_states.txt
$ R
>  library(tm)
>  library(wordcloud)
>  library(RColorBrewer)
>  corpus <- Corpus(DirSource(pattern="*.txt"))
>  corpus <- tm_map(tm_map(tm_map(corpus, removePunctuation), tolower), function(x) removeWords(x, stopwords("english")))
>  tdMatrix <- as.matrix(TermDocumentMatrix(corpus))
>  tdMatrix <- sort(rowSums(tdMatrix), decreasing=T)
>  freqDF <- data.frame(words=names(tdMatrix), freq=tdMatrix)
>  colorPalette <- brewer.pal(8, "RdBu")
>  png(file="arizona_v_usa_wordcloud.png", bg="black")
>  wordcloud(freqDF$words, freqDF$freq, scale=c(8, 0.25), min.freq=10, random.order=F, rot.per=0.2, colors=colorPalette)
>  dev.off()
java law legal-informatics programming r technology tika

Insights by email

Get new insights by email

One email when we publish something new, and nothing when we don't. No tracking pixels, and leaving takes one click.

Lists

We'll send one email to confirm. See the privacy notice.

Working on something like this? Talk to us →