#!/bin/sh

SCORESET=0
if [ "x$1" != "x" ]; then
 SCORESET=$1
fi

#make evolve SCORESET=$SCORESET || exit 1

echo "STATISTICS REPORT FOR SPAMASSASSIN RULESET"
echo 
echo "Classification success on test corpora, at default threshold:"
echo

#./evolve -C -t 5 | egrep '^#'
./logs-to-c --spam=spam-validate.log --nonspam=nonspam-validate.log --threshold 5 --count --scoreset=$SCORESET | sed -e 's/^Reading.*//' -e '/^$/d'

echo
echo "Results on test corpora at various alternative thresholds:"
echo

# list a wide range of thresholds, so that we can make graphs later ;)
for thresh in -4 -3 -2 -1 0 1 2 3 4 4.5 5.5 6 6.5 7 8 9 10 12 15 17 20 ; do
  #./evolve -C -t $thresh | egrep '^#' | egrep -v '^# (Average|TOTAL)'
  ./logs-to-c --spam=spam-validate.log --nonspam=nonspam-validate.log --threshold $thresh --count --scoreset=$SCORESET | sed -e 's/^Reading.*//' -e '/^$/d'
  echo
done

echo
echo "Test hit frequencies, for spam and nonspam corpora:"
echo "(note: S/O indicates ratio of spam hits to overall hits for"
echo "each test, where 0.0 = hits only non-spam and 1.0 = hits only spam,"
echo "and the 'score' field should be ignored.)"
echo
cat freqs

version=`( cd .. ; ./build/get_version )`
echo
echo "Rule file versions for which these results apply:"
echo "(SpamAssassin Version string: $version)"
echo

( cd ../rules ; ls -l *.cf )
