[Spambayes] Interesting Request

Tony Meyer tameyer at ihug.co.nz
Tue Nov 2 01:45:48 CET 2004

> Is there any way to create a Windows based DLL of the main 
> SpamBayes engine? I have multiple ideas for how to use an API 
> like this and am 110% convinced this is the best spam 
> detection routine on the market.

What you are after, presumably, is the functionality contained in the
tokenizer.py and classifier.py scripts.  These take a message and convert it
to a set of tokens and take a set of tokens and a database and give a score
(respectively).  They're very simple to use - something like:

>>> import email
>>> msg = email.message_from_file(open("d:\\example.txt"))
>>> from spambayes.tokenizer import tokenize
>>> tokens = tokenize(msg)
>>> from spambayes.classifier import Classifier
>>> Classifier().spamprob(tokens)

(The score is 0.5, because the classifier hasn't learnt anything).  The
source is all well documented, and there are several simple scripts
(sb_filter, for example) that give good examples of how to do simple tasks
like scoring or training a message.

To create a DLL, you'd just write a Python script that did what you wanted,
then use something like py2exe to turn it into a DLL.


Please always include the list (spambayes at python.org) in your replies
(reply-all), and please don't send me personal mail about SpamBayes.
http://www.massey.ac.nz/~tameyer/writing/reply_all.html explains this.

More information about the Spambayes mailing list