Word Cloud book visualization

I thought it would be fun to visualize The Ethics of Anarcho-Capitalism as a word cloud, so I wrote a little script to produce one. Here is the result:

wordcloud_04

I was a little disappointed that the words freedom, liberty, and capital were not more prominent, but it’s my own fault for using other words more frequently.

Here is the python script (pastebin). It uses the WordCloud library to do most of the work:

#!/usr/bin/env python3

from wordcloud import WordCloud
import matplotlib.pyplot as plt

filename = 'chapters.html'
with open(filename) as f:
    text = f.read()

image = WordCloud(width=1920, height=1080, max_font_size=120, colormap='Spectral').generate(text)
image.to_file('/tmp/wordcloud.png')
plt.imshow(image, interpolation='bilinear')
plt.axis('off')
plt.show()

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: