[Spambayes-checkins] spambayes/spambayes message.py,1.29,1.30
Richie Hindle
richiehindle at users.sourceforge.net
Fri Jul 18 14:19:34 EDT 2003
Update of /cvsroot/spambayes/spambayes/spambayes
In directory sc8-pr-cvs1:/tmp/cvs-serv16669
Modified Files:
message.py
Log Message:
Whitespace normalisation.
Index: message.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/message.py,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** message.py 26 May 2003 06:43:24 -0000 1.29
--- message.py 18 Jul 2003 20:19:32 -0000 1.30
***************
*** 19,23 ****
have been trained differently than their classification, for fp/fn
assessment purposes.
!
Message is an extension of the email package Message class, to
include persistent message information. The persistent state
--- 19,23 ----
have been trained differently than their classification, for fp/fn
assessment purposes.
!
Message is an extension of the email package Message class, to
include persistent message information. The persistent state
***************
*** 29,53 ****
SBHeaderMessage extends Message to include spambayes header specific
manipulations.
!
Usage:
A typical classification usage pattern would be something like:
!
>>> msg = spambayes.message.SBHeaderMessage()
>>> msg.setPayload(substance) # substance comes from somewhere else
>>> id = msg.setIdFromPayload()
!
>>> if id is None:
>>> msg.setId(time()) # or some unique identifier
!
>>> msg.delSBHeaders() # never include sb headers in a classification
!
! >>> # bayes object is your responsibility
>>> (prob, clues) = bayes.spamprob(msg.asTokens(), evidence=True)
>>> msg.addSBHeaders(prob, clues)
!
!
A typical usage pattern to train as spam would be something like:
!
>>> msg = spambayes.message.SBHeaderMessage()
>>> msg.setPayload(substance) # substance comes from somewhere else
--- 29,53 ----
SBHeaderMessage extends Message to include spambayes header specific
manipulations.
!
Usage:
A typical classification usage pattern would be something like:
!
>>> msg = spambayes.message.SBHeaderMessage()
>>> msg.setPayload(substance) # substance comes from somewhere else
>>> id = msg.setIdFromPayload()
!
>>> if id is None:
>>> msg.setId(time()) # or some unique identifier
!
>>> msg.delSBHeaders() # never include sb headers in a classification
!
! >>> # bayes object is your responsibility
>>> (prob, clues) = bayes.spamprob(msg.asTokens(), evidence=True)
>>> msg.addSBHeaders(prob, clues)
!
!
A typical usage pattern to train as spam would be something like:
!
>>> msg = spambayes.message.SBHeaderMessage()
>>> msg.setPayload(substance) # substance comes from somewhere else
***************
*** 55,65 ****
>>> msg.delSBHeaders() # never include sb headers in a train
!
>>> if msg.getTraining() == False: # could be None, can't do boolean test
>>> bayes.unlearn(msg.asTokens(), False) # untrain the ham
!
>>> bayes.learn(msg.asTokens(), True) # train as spam
>>> msg.rememberTraining(True)
!
To Do:
--- 55,65 ----
>>> msg.delSBHeaders() # never include sb headers in a train
!
>>> if msg.getTraining() == False: # could be None, can't do boolean test
>>> bayes.unlearn(msg.asTokens(), False) # untrain the ham
!
>>> bayes.learn(msg.asTokens(), True) # train as spam
>>> msg.rememberTraining(True)
!
To Do:
***************
*** 128,132 ****
def _delState(self, msg):
del self.db[msg.getId()]
!
# This should come from a Mark Hammond idea of a master db
# For the moment, we get the name of another file from the options,
--- 128,132 ----
def _delState(self, msg):
del self.db[msg.getId()]
!
# This should come from a Mark Hammond idea of a master db
# For the moment, we get the name of another file from the options,
***************
*** 147,151 ****
self.c = None
self.t = None
!
# non-persistent state includes all of email.Message.Message state
--- 147,151 ----
self.c = None
self.t = None
!
# non-persistent state includes all of email.Message.Message state
***************
*** 167,171 ****
# to try to extract important headers regardless of malformations
prs._parsebody(self, fp)
!
def setId(self, id):
if self.id:
--- 167,171 ----
# to try to extract important headers regardless of malformations
prs._parsebody(self, fp)
!
def setId(self, id):
if self.id:
***************
*** 176,184 ****
if not type(id) in types.StringTypes:
! raise TypeError, "Id must be a string"
!
self.id = id
msginfoDB._getState(self)
!
def getId(self):
return self.id
--- 176,184 ----
if not type(id) in types.StringTypes:
! raise TypeError, "Id must be a string"
!
self.id = id
msginfoDB._getState(self)
!
def getId(self):
return self.id
***************
*** 198,202 ****
# append function), but does not, so we do it here
return self._force_CRLF(email.Message.Message.as_string(self))
!
def modified(self):
if self.id: # only persist if key is present
--- 198,202 ----
# append function), but does not, so we do it here
return self._force_CRLF(email.Message.Message.as_string(self))
!
def modified(self):
if self.id: # only persist if key is present
***************
*** 236,240 ****
self.t = isSpam
self.modified()
!
def __repr__(self):
return "spambayes.message.Message%r" % repr(self.__getstate__())
--- 236,240 ----
self.t = isSpam
self.modified()
!
def __repr__(self):
return "spambayes.message.Message%r" % repr(self.__getstate__())
***************
*** 250,257 ****
'''Message class that is cognizant of Spambayes headers.
Adds routines to add/remove headers for Spambayes'''
!
def __init__(self):
Message.__init__(self)
!
def setIdFromPayload(self):
try:
--- 250,257 ----
'''Message class that is cognizant of Spambayes headers.
Adds routines to add/remove headers for Spambayes'''
!
def __init__(self):
Message.__init__(self)
!
def setIdFromPayload(self):
try:
***************
*** 265,269 ****
'''Add hammie header, and remember message's classification. Also,
add optional headers if needed.'''
!
if prob < options['Categorization','ham_cutoff']:
disposition = options['Headers','header_ham_string']
--- 265,269 ----
'''Add hammie header, and remember message's classification. Also,
add optional headers if needed.'''
!
if prob < options['Categorization','ham_cutoff']:
disposition = options['Headers','header_ham_string']
***************
*** 274,286 ****
self.RememberClassification(disposition)
self[options['Headers','classification_header_name']] = disposition
!
if options['Headers','include_score']:
self[options['Headers','score_header_name']] = str(prob)
!
if options['Headers','include_thermostat']:
thermostat = '**********'
self[options['Headers','thermostat_header_name']] = \
thermostat[:int(prob*10)]
!
if options['Headers','include_evidence']:
hco = options['Headers','clue_mailheader_cutoff']
--- 274,286 ----
self.RememberClassification(disposition)
self[options['Headers','classification_header_name']] = disposition
!
if options['Headers','include_score']:
self[options['Headers','score_header_name']] = str(prob)
!
if options['Headers','include_thermostat']:
thermostat = '**********'
self[options['Headers','thermostat_header_name']] = \
thermostat[:int(prob*10)]
!
if options['Headers','include_evidence']:
hco = options['Headers','clue_mailheader_cutoff']
***************
*** 312,316 ****
except KeyError:
self["Subject"] = disposition
!
if "header" in options['pop3proxy','add_mailid_to']:
self[options['pop3proxy','mailid_header_name']] = self.id
--- 312,316 ----
except KeyError:
self["Subject"] = disposition
!
if "header" in options['pop3proxy','add_mailid_to']:
self[options['pop3proxy','mailid_header_name']] = self.id
More information about the Spambayes-checkins
mailing list