procmail
[Top] [All Lists]

Re: Score and _AND_

2002-10-08 15:15:22
| I just wandering:  Suppose one wants to score three words and
| s/he wants to be sure that this three words are exist in the text.
| The only way that I can see is:
|
| :0 B
| * word1
| * word2
| * word3
| {
| :0 Bfb
| * 1^1 word1
| * 1^1 word2
| * 1^1 word3
| | /do/something/with $=
| }
|
| Now, we can be sure that  $= >= 3  and every word appearances
| at least one time i.e. if  $= == 5  then the word1 could not
| appearance 3 times.
|
| There is a big deficiency in this recipe - procmail pass twice
| on the data.  Any idea?

I'm not sure exactly what you want, Udi.  You want to know how many times each
regexp appears in the body and make sure that each is there at least once, and
then do something with the total number of appearances of all three, but scan
the body only three times instead of six?

Well, here's an easy way to reduce it to four passes, as long as there's no
overlap:

 :0Bbf
 * pattern1
 * pattern2
 * pattern3
 * 1^1 pattern1|pattern2|pattern3
 | /do/something/with $=

or with three passes:

 :0B
 * 1^1 pattern1
 {
  score1 = $=

  :0B
  * 1^1 pattern2
  {
   score2 = $=

   :0B
   * 1^1 pattern3
   {
    :0bf
    * $ $=^0
    * $ $score2^0
    * $ $score1^0
    | /do/something/with $=
   }
  }
 }



_______________________________________________
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>