#!/bin/sh

if [ $# -gt 0 ] ; then
  ./logs-to-c $* || exit 1
# else assume we're using the default ruleset
fi
make evolve || exit 1

version=`( cd .. ; ./build/get_version )`

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

  ./evolve -C -t 5 | egrep '^#'

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

  for thresh in 5.5 6 6.5 7 8 9 10 12 15 ; do
    ./evolve -C -t $thresh | egrep '^#' | egrep -v '^# (Average|TOTAL)'
    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

  echo
  echo "Rule file versions for which these results apply:"
  echo "(SpamAssassin Version string: $version)"
  echo

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

) > ../rules/STATISTICS.txt

ls -l ../rules/STATISTICS.txt
