[Spambayes] db query

Skip Montanaro skip at pobox.com
Tue Apr 1 09:10:03 EST 2003


    >> Look in your database for the spamprob on 'proto:http'.  My bet is
    >> that it's near neutral

    bill> i have been trying to figure out how to query the db for sometime
    bill> now to get this very info. can someone point me to the
    bill> FAQ/note/msg/comment/util that allows one to do so?

I doubt there's anything in the faq about it.  Here's how to go about
printing the raw spam/ham counts for a given token:

    >>> import shelve
    >>> db = shelve.open("hammie.db")
    >>> print db.get("proto:http")
    (12106, 20272)
    >>> db.close()

The only reason I used db.get("proto:http") instead of db["proto:http"] is
that there's no guarantee that any particular token is present in your
database.  (This was a poor example to demonstrate that.)

I can't remember if the first element is the number of times it appears in
ham or spam.  A little guesswork suggests the first element is nspam:

    >>> print db.get("viagra")
    (122, 4)

Skip




More information about the Spambayes mailing list