pydspam
1.4
|
Hold context for a DSPAM message operation Each context creates a new DSPAM_CTX
struct within libdspam.
More...
Public Member Functions | |
def | __init__ (self, username, mode, flags=0, group=None, home=None) |
Initialize dspam context. More... | |
def | process (self, msg, sig=None) |
Calls dspam_process(DSPAM_CTX ctx, const char *msg) More... | |
def | addattribute (self, key, val) |
Add configuration attribute to context. More... | |
def | clearattributes (self) |
Clear configuration attributes from this context. | |
def | attach (self, dbh=None) |
Attaches storage driver to context. More... | |
def | set_signature (self, tag, sig) |
Store a signature using the attached storage driver. More... | |
def | get_signature (self, tag) |
Retrieve a signature stored using the attached storage driver. More... | |
def | delete_signature (self, tag) |
Delete a signature stored using the attached storage driver. More... | |
def | verify_signature (self, tag) |
Verify a signature stored using the attached storage driver. More... | |
def | detach (self) |
Detaches storage driver from context. More... | |
def | tokenize (self, header, body) |
Tokenize the header and body of a message, and return a dictionary of token,freq tuples by hash. | |
def | destroy (self) |
Destroy context, releasing all resources. | |
Public Attributes | |
result | |
Result of DSPAM classification. | |
classification | |
Callers classification. | |
source | |
Source of callers classification. | |
tokenizer | |
Tokenizer algorithm. | |
algorithms | |
Classification algorithms to employ. More... | |
training_mode | |
Training mode. More... | |
totals | |
Totals. More... | |
probability | |
Probability. More... | |
factors | |
Factors. More... | |
Hold context for a DSPAM message operation Each context creates a new DSPAM_CTX
struct within libdspam.
The dspam module in turn creates a ctx object.
Most application interaction with libdspam takes places via the ctx object for the connection.
def dspam.ctx.__init__ | ( | self, | |
username, | |||
mode, | |||
flags = 0 , |
|||
group = None , |
|||
home = None |
|||
) |
Initialize dspam context.
username | dspam account the account applies to |
mode | dspam processing mode: DSM_* |
flags | dspam processing flags: DSF_* |
group | dspam group |
home | dspam home dir, libdspam compiled default if none. On RedHat/Fedora, this is /var/lib/dspam . |
def dspam.ctx.addattribute | ( | self, | |
key, | |||
val | |||
) |
Add configuration attribute to context.
Context configuration controls the tokenizer, storage driver, and other aspects of DSPAM for this context.
key | str key |
val | str value |
def dspam.ctx.attach | ( | self, | |
dbh = None |
|||
) |
Attaches storage driver to context.
Driver specific context configuration should be done before attaching the driver.
dbh | a storage handle obtained from the driver ctx in a driver specific way so it can be reused, or None |
def dspam.ctx.delete_signature | ( | self, | |
tag | |||
) |
Delete a signature stored using the attached storage driver.
Throws an exception if the tag is not present.
tag | str - unique tag assigned to the signature |
def dspam.ctx.detach | ( | self | ) |
Detaches storage driver from context.
def dspam.ctx.get_signature | ( | self, | |
tag | |||
) |
Retrieve a signature stored using the attached storage driver.
Throws an exception if the tag is not present. Use verify_signature to check first.
tag | str - unique tag assigned to the signature |
def dspam.ctx.process | ( | self, | |
msg, | |||
sig = None |
|||
) |
Calls dspam_process(DSPAM_CTX ctx, const char *msg)
msg | the email message to process |
sig | a signature obtained from self.signature, or None |
def dspam.ctx.set_signature | ( | self, | |
tag, | |||
sig | |||
) |
Store a signature using the attached storage driver.
The tag should be suitable for a filename.
tag | str - unique tag assigned to the signature |
sig | Binary signature obtained from self.signature |
def dspam.ctx.verify_signature | ( | self, | |
tag | |||
) |
Verify a signature stored using the attached storage driver.
Use verify_signature to check first.
tag | str - unique tag assigned to the signature |
dspam.ctx.algorithms |
Classification algorithms to employ.
Use any combination of DSA_* and DSP_* flags.
dspam.ctx.factors |
Factors.
A list of token_name,weight tuples. These are the factors used by dspam to compute the probability.
dspam.ctx.probability |
Probability.
The probability that the message is spam according to libdspam.
dspam.ctx.totals |
Totals.
A tuple of 8 ints: (spam_learned, innocent_learned, spam_misclassified, innocent_misclassified, spam_corpusfed, innocent_corpusfed, spam_classified, innocent_classified)
dspam.ctx.training_mode |
Training mode.
Use one of DST_* flags.