mutewinter / Showbot

🤖 An IRC Bot and Website for 5by5.tv written with the Cinch and Sinatra frameworks
MIT License
90 stars 31 forks source link

Word Clouds #47

Closed gouwens closed 11 years ago

gouwens commented 11 years ago

I ported my title suggestion word cloud project into Showbot so that clouds can be created off the live data. This version uses the d3-cloud Javascript layout engine by Jason Davies (with slight modifications) to create the clouds themselves.

There are a few new interfaces that generate the clouds. Going to /clouds_between/[days_ago_1]/[days_ago_2] will create clouds for all the episodes in the time range specified. So, for example, if you wanted to see the clouds for the past week, you could go to /clouds_between/0/7. Warning: The first time any cloud generation happens, it will take a very long time because it has to count terms across all episodes in the database. After that, it will update those counts by going through new episodes that occurred since the generator last ran.

Another interface is /cloud_svg/[year]/[month]/[day]/[index], which will generate a single cloud by itself. The index tells it which episode you want on that day (i.e. if there were three episodes you can choose 0, 1, or 2). The idea behind this view is that it could be more easily saved as a PNG or SVG by something like phantomjs. To find out how many episodes happened on a given day, you can access /num_clouds_on_date/[year]/[month]/[day], which will return a JSON structure that looks like: { "num_clouds": <number of clouds that day> }

Again, I'm not sure what exactly would need to happen on the server to automatically generate and save the images, but I tried to create the components that would allow it to happen. I'm certainly happy to work on it more to better adapt it for a particular situation.

In any case, here's an example created for Hypercritical #57 (using all the Hypercritical titles as the database): cloud_test

mutewinter commented 11 years ago

Oh god this is so cool. I'm going to look it over this weekend. I'll let you know how it goes!

mutewinter commented 11 years ago

Added this, no link for now while we test it on the live site using the URLs you described above.

mutewinter commented 11 years ago

Here's one working on the live site!

http://showbot.5by5.tv/cloud_svg/2013/4/17/0

mutewinter commented 11 years ago

The database might be exploding, but it's worth it to see those pretty clouds.