26 June 2008

Contested Word Cloud

My friend Joe put up a blurb on a site called wordle that creates word clouds from text. Word clouds are a collection of the common words in a set of words, with size and intensity derived from their frequency in the set.

I thought it would be cool to see what the contents of this blog look like so I played with some code (see below) and came up with this:

To do this I used C#, the Google Data API for Blogger and the following code to rip out the contents of the blog, strip the HTML tags (very necessary). I output the contents to a form field and then copied it into wordle.

FeedQuery fq = new FeedQuery();
fq.Uri = new Uri("http://www.blogger.com/feeds/[blog id here]/posts/default");
Service service = new Service();
AtomFeed f = service.Query(fq);

string output="";

foreach (AtomEntry blogEntry in f.Entries)
output += blogEntry.Content.Content;
string strResult = Regex.Replace(output, @"<(.|\n)*?>", string.Empty);

A fun little project over all.

No comments: