procmail
[Top] [All Lists]

Re[2]: Counting hits

2004-06-03 08:37:26
On Thu, 03 Jun 2004 09:21:29 -0400 (EDT) "fleet(_at_)teachout(_dot_)org" wrote: 

On Thu, 3 Jun 2004, Dallman Ross wrote:
You ought to be able to count most anything right in native procmail
language.

I tried scoring; but got confused.  In any event, I wasn't sure I could
construct a scoring recipe that looked like:

:0
* -5^0
* 1^1 condition
* 1^1 condition
* 1^1 condition

# repeated 35 or 40 times (with different conditions on each line, of
course.)

spam

Even if I did something like the above, how would I identify which of the
conditions got "hit" and place that info into the header.

Maybe you can explain at a more basic level what you are trying to do?

Basically, I'm trying to identify a spam condition, assign a number value
to it, and "formail" the condition description into the header of the
message. (I can do the formail part - in an equally inefficient manner -
and don't have that part included in the example.  I suppose it would
replace the "LOG" function eventually.)

OK -- my mortgage broker left a message on the machine while I was looking
at this so I don't have time to read 'man procmailsc' thoroughly as I have
to call him back -- I really want the property I'm looking at.

I don't use scoring at this time so I haven't played with it enough to
fully understand it. There was a thread in here earlier (a month or so
ago?) about tagging which conditions of a group were met. I don't recall it
ever being completely solved and I'm not looking in the archive at the
moment. If it was solved someone please point fleet to the archived thread.

My example below is NOT in proper format. I'm typing fast. It should be
understandable enough for someone to 'flesh out'.

The linux kernel uses ANDed bits to identify all sorts of things. There
should be a shell routine or perl function to break an ANDed value out into
it's component parts. So, why not use that in procmail scoring to create
your "These conditions got hit" header?

SET1=0
:0
1^1  *C1
1^2  *C2
1^4  *C3
1^8 *C4
1^16 *C5
1^32 *C6
1^64 *C7
{SET1=$=}

|routine.pl 

[routine.pl takes the value and sets a variable "SET1_TEXT" based on the
total value of SET1:

1= C1
3= C1+C2
5= C1+C3
... 
127= C1+C2+C3+C4+C5+C6+C7

Since you say you have 35 or 40 conditions I would suggest breaking it into
groups of 6 or 7 and crafting the TEXT variable returned by the external
routine in such a way as to keep its length reasonable.

SET1_TEXT="X-SPAM_SET_1: C1, C2, C3, C7"
SET2_TEXT="X-SPAM_SET_2: C1, C3, C5"

Use nesting to separate the sets and at the end add the values of SET1,
SET2, ..., SETn to get a final value to determine where you want to deliver
the message.

The part I'm REALLY not sure about is what's going to happen if a
particular condition is met more than once. That's the part where 'man
procmailsc' confused me a bit. It says if a score is set up as w^x then on
the first match it adds w and on subsequent matches adds w*x then w*x*x
then ...

Oh -- waitaminit. The scoring section should be set up like this:

SET1=0
:0
1^0  *C1
2^0  *C2
4^0  *C3
8^0 *C4
16^0 *C5
32^0 *C6
64^0 *C7
{SET1=$=}

That way the first match will add the base value and subsequent matches
will add 0.

If you WANT multiple matches of a particular condition to add more points
someone else will have to work out the math. My brain is too foggy right
now and I have a call to make. 2 acres, 3 year old 2 bed/ 2 bath home,
garage (detached), and a Dodge diesel quad cab truck thrown in -- all I
need is a stinking $45,000 US loan to go through.

Gerald


_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>