-----BEGIN PGP SIGNED MESSAGE-----

In article <E0ECBA30-6F84-11D7-A131-000A95676A62 / pragprog.com>,
Dave Thomas  <dave / pragprog.com> wrote:
>
>On Tuesday, April 15, 2003, at 03:41 PM, Brian Candler wrote:
>> No, it certainly is filtered. Look at the headers of the spams which 
>> get
>> through: for example the most recent one had
>>
>> X-Spam-Status: No, hits=3.2 required=5.0 
>> tests=INVALID_DATE_NO_TZ,DEAR_SOMEBODY,SUPERLONG_LINE,RCVD_IN_ORBZ 
>> version=2.20
>> X-Spam-Level: ***
>>
>
>The mail-news gateway is filtered: I run SpamAssassin on messages going 
>to both directions. However, the mailing list itself is open, so anyone 
>can post to ruby-talk directly.
>
>In addition, spammers seem to be getting wise to SpamAssassin: I'm 
>seeing more and more e-mail get through (both personally and in the 
>mail-news gateway). I was on the point of reducing the threshold a bit 
>to see if it made things better. Does anyone have any experience to 
>share here?
>

_ You might want to look at something statistical like
  ifile. It's a general purpose text-file sorter that does
  a very good job when choosing between spam/non-spam for
  mailing lists. Here's the URL 

http://www.nongnu.org/ifile/

  and just to keep some Ruby content in the message. Here's
  my ruby module for dealing with ifile. I've heard rumors
  that SpamAssassin can also now do this kind of statistical
  matching. 

_ Booker C. Bense  

#
# $Id: ifile.rb,v 1.2 2003/01/22 19:07:50 bbense Exp $
#
# Ifile, a class for interacting with ifile program.
# Get ifile at http://www.nongnu.org/ifile/
#
# Booker C. Bense <bbense / slac.stanford.edu> 
#

require 'open3'

module Ifile

# This is the wrong name, but I can't think of anything better.
class Process
  # Tell me where ifile lives.
  def initialize(path="/var/local/bin/ifile",args="--verbosity=0") 
    if FileTest.executable?(path) then 
      @ifile = path
      @args = args
    else
      raise ArgumentError 
    end 
  end

  # Given a message, query folders

  def query(msg)
    results = Array.new
    output = self.run_ifile(msg,"--query ")
    i = 0 
    output.each do |line|
      # Format of output is folder score
      folder , score = line.split
      if ( folder && score ) then 
	tmp = Hash.new
	tmp['folder'] = folder
	tmp['score'] = score.to_f
	tmp['position'] = i 
	results << tmp 
	i = i + 1 
      end
    end 
    return results
  end 

  # Add a message to a folder
  def add(msg,folder)
    output = self.run_ifile(msg,"--insert=#{folder}") 
  end
  # Delete a message from a folder
  def delete(msg,folder) 
    output = self.run_ifile(msg,"--delete=#{folder}") 
  end 

  # Refile
  def refile(msg,oldfolder,newfolder) 
    self.delete(msg,oldfolder) 
    self.add(msg,newfolder)
  end 
# internal methods
  
  
  def run_ifile(msg,args) 
    stdin, stdout, stderr = Open3.popen3("#{@ifile} #{@args} #{args}")
    #write msg to ifile
    msg.each { |line| stdin.puts line } 
    stdin.close
    #Read output 
    output = stdout.readlines
    stdout.close
    stderr.close
    return output
  end 


end


end # module Ifile
 

#Testing 
if ( __FILE__ == $0 ) then

  ifile = Ifile::Process.new("/var/local/bin/ifile","-v 0 -b ./idata.test")

  test = File.open("./test.msg") 

  msg = test.readlines

  results = ifile.query(msg) 
  p results

  ifile.add(msg,"test")

  results = ifile.query(msg) 
  p results

  ifile.delete(msg,"test")



  results = ifile.query(msg) 
  p results

  ifile.add(msg,"wrong")

  results = ifile.query(msg) 
  p results

  ifile.refile(msg,"wrong","test")
  
  results = ifile.query(msg) 
  p results

  ifile.delete(msg,"test")

end 



-----BEGIN PGP SIGNATURE-----
Version: 2.6.2

iQCVAwUBPqbrTWTWTAjn5N/lAQGUKAP+IDrWX5OYCAu6CHgRwoaxLbxmOtNFir6t
2o6/RZ5vmRQCiT4gBZqPrRs7Hf5yKYGD//fUc8KIKxKLzmp1we3XVNd6kovmZQ0k
QdsOvaTN4PQw5Q8pIqMFL9vrZ+Bc4lGh317RGsvhG3SRQgi8P7Fk4LY3lwttXDGV
zQtUYryJv24=
=/hX0
-----END PGP SIGNATURE-----