#!/bin/bash # crmtrain -- Script for training crm114 discriminator (spam filter) # with big amounts of e-mail messages, either as SPAM or # HAM. Use the "Export" command in Alpine mailer to store # SPAM as: s1, s2, s{3,4,5...} and HAM as: n1, n2, n{3,4,5...} # Copyright (C) 2008 Adrian C. # Licensed under the WTFPL # Directories spamdir=$HOME/spam crmdir=$HOME/.crm114 # Mail filter trainer=mailfilter.crm #trainer=mailreaver.crm if [[ -z $1 ]]; then echo "Usage: $0 [spam|ham] [num]" echo "Train crm114 with N spam or ham messages." exit 1 else # Determine the number of messages if [ $2 ]; then spamnum=$2 else # Fallback to 1 spamnum=1 fi case "$1" in spam) for i in $(seq 1 $spamnum); do # SPAM is saved as sN # Learning spam, force to go around a known bug $crmdir/$trainer -u $crmdir --learnspam --force < $spamdir/s$i /bin/rm $spamdir/s$i sleep 2 # Don't rush things done ;; ham) for i in $(seq 1 $spamnum); do # HAM is saved as nN # Learning non-spam is better, don't force $crmdir/$trainer -u $crmdir --learnnonspam < $spamdir/n$i /bin/rm $spamdir/n$i sleep 2 # Don't rush things done ;; *) echo "Error: '$1' is not a valid e-mail tag." ;; esac exit 0 fi