Re: Learning/relearning twice; effect on database

"Clemens Fischer" <[email protected]> 21 Oct 2002 14:33:53 +0200
Newsgroups gmane.mail.ifile.general
Message-ID <[email protected]>
[email protected]:

> Brilliant.  I'll just add another header saying 'I've been
> recategorised, skip me' which procmail can then use to ignore messages
> on a future pass through.

would you care to share your script?  mine is essentially:

FOLDER=`/root/bin/ifile-l ERROR`.spool

in procmail, with ifile-l beeing:

---------------------8<------------------------
#!/bin/sh
# $Header: /root/bin/RCS/ifile-l,v 1.1.1.4 2002/08/20 18:15:59 root Exp root $
/usr/local/bin/ifile -cQ && /root/bin/ifile-ll ifile || echo "${1:-ERROR}"
---------------------8<------------------------

and ifile-ll beeing:

---------------------8<------------------------
#!/bin/sh
# $Header: /root/bin/RCS/ifile-ll,v 1.1.1.1 2002/03/13 13:57:14 root Exp $
# accuracy update
debug=true
#debug=echo
case "${1:-ifile}" in
ifile)
	bumpifile=1
	bumpirefile=0
	;;
irefile)
	bumpifile=0
	bumpirefile=1
	;;
*)
	bumpifile=0
	bumpirefile=0
	;;
esac
accfn="${HOME}/.idata.acc"
acclck="${HOME}/.idata.acclck"
if [ -f "${accfn}" ]; then
	if lockfile -r0 -l1024 "$acclck" 2>/dev/null; then
		trap "rm -f ${acclck}" 1 2 3 13 15
		accifile=$(head -1 "$accfn")
		accirefile=$(tail -1 "$accfn")
		$debug acc: $accifile $accirefile
		$debug bump: $bumpifile $bumpirefile
		accifile=$(($accifile + $bumpifile))
		accirefile=$(($accirefile + $bumpirefile))
		$debug acc: $accifile $accirefile
		echo $accifile > $accfn
		echo $accirefile >> $accfn
	fi
elif lockfile -r0 -l1024 "$acclck" 2>/dev/null; then
	trap "rm -f ${acclck}" 1 2 3 13 15
	accfn="${HOME}/.idata.acc"
	echo 1 > $accfn
	echo 0 >> $accfn
fi
rm -f "${acclck}"
---------------------8<------------------------

the reason for factoring out ifile-ll is that i need the same
mechanism for refiles.  ifile-ll takes care of the accuracy counters,
that are also updated on refiles, and the accuracy data-file needs
locking.

---------------------8<------------------------
#!/bin/sh
# $Header: /root/bin/RCS/irefile,v 0.1.1.7 2002/09/01 16:00:21 root Exp root $

#debug=echo
debug=true

usage () {
	echo "usage: $0 <from> [<to>].  this will take the message
on stdin out the <from>-folder and into <to>.  in two-folder anti-spam
systems the <to>-folder is implied, but has to be confirmed."
}

case "$0" in
*inbox) exec irefile INBOX
	;;
*spam)	exec irefile spam
	;;
esac

[ "x$1" = "x" ] && {
	usage
	exit 1
}

idata=${HOME}/.idata
from="$1" to="$2"

TMPDIR=${TMPDIR:=/tmp}
TMPFILE=`mktemp -t irefile` || exit 1
cat > $TMPFILE

confirm=true
[ "x$2" = "x" ] && {
	confirm=echo
}

folders=$(head -1 $idata)
nfolders=0
for i in $folders; do nfolders=$(($nfolders + 1)); done

[ "x$to" = "x" ] && {
	[ $nfolders -gt 2 ] && {
		echo "nfolders: $nfolders, no implicit <to> possible."
		exit 2
	}
	case "$from" in
	"spam") to=INBOX
		;;
	"INBOX") to=spam
		;;
	*)
		echo "from: $from, must be {spam, INBOX}."
		exit 2
		;;
	esac
}
#setlock /tmp/ifile.lck ifile -d "$from" < $TMPFILE &&
#setlock /tmp/ifile.lck ifile -i "$to" < $TMPFILE &&
#ifile -d "$from" -u "$to" < $TMPFILE &&
ifile -d "$from" -i "$to" < $TMPFILE &&
ifile -q < $TMPFILE &&
rm -f $TMPFILE &&
ifile-ll irefile &&
$confirm "$0: ok." &&
exit 0

ex=$?
$confirm "$0 returned $ex: not ok, $TMPFILE not removed."
exit $ex
---------------------8<------------------------

the twist with my irefile is that by calling it as irefile-spam it
refiles from spam into INBOX.  calling it as irefile-INBOX refiles
from the INBOX into the spam-folder.

once your scripts are stable, jason will no doubt place a link to them
on the ifile page if you want this.

clemens

ps:  the counters right this moment are:
     13990 88, ie. 13990 correct filings against 88 refiles.  that's
     an accuracy better then 99% for the two categories spam/non-spam,
     which are very distinct by the nature of the eleete lists i
     subscribe to ;)  ifiles precision is much worse in "borderline"
     cases with very similiar categories, but you'll find correct hits
     in the top three always!

------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get 128 Bit SSL Encryption!
http://us.click.yahoo.com/JjlUgA/vN2EAA/kG8FAA/CefplB/TM
---------------------------------------------------------------------~->

To UNSUBSCRIBE, send an empty message to
[email protected]

ifile web site: http://www.ai.mit.edu/~jrennie/ifile/ 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/