#!/usr/bin/perl -T use strict; use warnings; use IO::Handle; my (%tagged,%date); ; ; # eat the header # read in and count all the links my $start = time; while () { s/\r\n//; my ($tag_id, $link_id, $link_date, $tag_name) = split /\t/, $_; push @{$tagged{$tag_name}}, $link_id; $date{$link_id} = (split / /, $link_date)[0]; if (time-$start > 1) { STDERR->autoflush(1); print STDERR "."; $start = time; } } print STDERR " done reading.\n"; sub ago($) { my $today = "2008-04-09"; # date of infodump my @today = split /-/, $today; my @ago = split /-/, $_[0]; # coarse is fine here, I'm only using it for color return ($today[2]-$ago[2]) + 30*($today[1]-$ago[1]) + 365*($today[0]-$ago[0]); } sub color_ago($) { # fresh = dark, old = light, oldest = 16*30 days my $ago = max(ago($_[0]),0) / (16 * 30); return "#" . (sprintf '%02x', 0xff * min($ago,1) )x3; } my @sorted = reverse sort { @{$tagged{$a}} <=> @{$tagged{$b}} } (keys %tagged); sub max($$) { my ($a,$b) = @_ ; $a >= $b ? $a : $b } sub min($$) { my ($a,$b) = @_ ; $a <= $b ? $a : $b } my @topfew = @sorted[0..min($#sorted,149)]; # list the most-used tags by recency of use foreach (@topfew) { @{$tagged{$_}} = sort { $date{$a} cmp $date{$b} } @{$tagged{$_}} ; } # tags with several recent questions show up near the top @topfew = reverse sort { $date{${$tagged{$a}}[-10]} cmp $date{${$tagged{$b}}[-10]} } @topfew; print< Popular tags on Ask Metafilter EOF print<Recent questions using popular tags on Ask Metafilter
  • Made from a 2008-04-09 infodump using this lousy code.
  • Recently used tags near the top.
  • Frequently used tags on darker lines.
  • Links generally get older/fainter as you move down and right.
  • Date seems to be date of tagging rather than date of posting.
  • Hover text should contain post title but that wasn't in the infodump.
  • 20,000 questions on frequently-discussed topics
EOF print qq{
\n}; print qq{\n}; foreach my $tag (@topfew) { my $line = qq{\n"; } print "
} . qq{$tag:} . qq{} . qq{+} . qq{($n)
\n"; print "
\n"; print < EOF