#!/opt/bin/perl ## ## Spam Recognition System -- fully-functional prototype in perl ## (to be recoded with additional functionality in C or Objective-C) ## ## Based on algorithms described by Paul Graham in: ## http://www.paulgraham.com/spam.html ## ## $Id: dbdump.pl,v 1.1 2002/08/22 02:53:07 dgc Exp $ ## dgc@uchicago.edu ## ($pdir = $0) =~ s!/[^/]+$!!; eval 'push(@INC, $pdir); require "lib.pl"'; sub usage { print STDERR "usage: $0 -s {P|N|R}\n"; } sub dump { my ($h, $sorted) = @_; map { print "$_ ", $h->{$_}, "\n"; } keys %{$h}; } sub main { my ($P, $N, $R); my $h; my $sorted = 0; if ($ARGV[0] eq "-s") { $sorted = 1; shift @ARGV; } lockdb(); ($P, $N) = mapcontext(); $R = maprate(); if (lc($ARGV[0]) eq "p") { &dump($P->{stats}, $sorted); } elsif (lc($ARGV[0]) eq "n") { &dump($N->{stats}, $sorted); } elsif (lc($ARGV[0]) eq "r") { &dump($R, $sorted); } else { usage; unmapcontext($P, $N); unmaprate($R); unlockdb(); exit(2); } unmapcontext($P, $N); unmaprate($R); unlockdb(); } &main;