xref: /plan9/mail/lib/isspam.rc (revision 4246b6162acdbb658503b8bdc98024362bfbf0fe)
1#!/bin/rc
2
3if (~ $#USER 0)
4	USER=$user
5cd /mail/box/$USER
6rfork en
7
8TMP=/tmp/spam.$sysname.$pid
9sed '/^$/,$ s/^From / From /' >$TMP.msg
10upas/fs -f $TMP.msg
11{
12	echo '# hash table'
13	upas/msgcat $TMP.msg | upas/msgtok |
14		grep -v '^....................(.*)	' |
15		sed 's/$/	1/'
16	} >$TMP.tok
17
18x=`{upas/bayes -k _prof.mbox _prof.spam ~ $TMP.tok}
19#echo xx $x xx >>/tmp/spam
20#ls -l _prof.mbox _prof.spam  $TMP.tok>>/tmp/spam
21where=$x(1)
22prob=$x(2)
23echo $where $prob
24*=($x)
25shift 2
26while(! ~ $#* 0){
27	echo '	' $1 $2
28	shift 2
29}
30rm -f $TMP.tok $TMP.msg
31if (~ $where *spam*){
32	exit ''
33}
34if not {
35	exit 'is ok'
36}
37