[Spambayes] Client/server model

Neale Pickett neale@woozle.org
Thu Oct 17 23:22:34 2002


So then, Greg Ward <gward@python.net> is all like:

> If there are multiple client implementations, then spreading work across
> clients also means duplicating code.  Yuck.  Based on my experience with
> SA, I think I'd prefer a model like this:
> 
>   cli sends message headers
>   svr parses the headers
>   cli sends message body OR individual attachments
>       [ie. the protocol needs some state so the client can say,
>        "I'm sending you the headers now", or "I'm sending you the
>        entire body now", or "I'm sending one attachment now"]
>   svr parses the message body/attachments/whatever
>   cli tells the server what it wants: eg. "give me the
>       X-Hammie-Disposition header", or "give me just the score", or
>       "give me the top-N scoring words and their probabilities"
>   svr gives the client what it wants

I'm not sure that the tokenizer would be too amenable to splitting the
header from the body, although if someone can think of a way to do that,
it certainly would rock my world, as it'd make this technique *way* more
accessible to $FIRM's embedded product.

But if you just want the score, you can do that.  Easy squeezy:

    #! /usr/bin/env python

    import xmlrpclib
    import sys

    RPCBASE="http://localhost:65000"

    msg = sys.stdin.read()
    x = xmlrpclib.ServerProxy(RPCBASE)
    m = xmlrpclib.Binary(msg)
    score = x.score(m)
    print "You get", score, "points."

You can even pass a second (true) argument to x.score to get back a list
of the contributing words.

I wrote hammiecli to show how easy it is to use hammiesrv.  You don't
have to do it my way though--feel free to write your own 6 lines of code
:)

Neale