[Spambayes-checkins] spambayes/Outlook2000 train.py,1.23,1.24

Mark Hammond mhammond at users.sourceforge.net
Mon Feb 3 18:19:07 EST 2003


Update of /cvsroot/spambayes/spambayes/Outlook2000
In directory sc8-pr-cvs1:/tmp/cvs-serv11695

Modified Files:
	train.py 
Log Message:
For the message db to be able to work with a bsddb database, we use string values rather than integers, and avoid the use of "get()"

Index: train.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/train.py,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** train.py	14 Jan 2003 05:38:20 -0000	1.23
--- train.py	4 Feb 2003 02:19:05 -0000	1.24
***************
*** 18,29 ****
  # latter changes after a Move operation - see msgstore.py
  def been_trained_as_ham(msg, mgr):
!     spam = mgr.message_db.get(msg.searchkey)
!     # spam is None
!     return spam == False
  
  def been_trained_as_spam(msg, mgr):
!     spam = mgr.message_db.get(msg.searchkey)
!     # spam is None
!     return spam == True
  
  def train_message(msg, is_spam, mgr, rescore=False):
--- 18,29 ----
  # latter changes after a Move operation - see msgstore.py
  def been_trained_as_ham(msg, mgr):
!     if not mgr.message_db.has_key(msg.searchkey):
!         return False
!     return mgr.message_db[msg.searchkey]=='0'
  
  def been_trained_as_spam(msg, mgr):
!     if not mgr.message_db.has_key(msg.searchkey):
!         return False
!     return mgr.message_db[msg.searchkey]=='1'
  
  def train_message(msg, is_spam, mgr, rescore=False):
***************
*** 36,40 ****
      from spambayes.tokenizer import tokenize
  
!     was_spam = mgr.message_db.get(msg.searchkey)
      if was_spam == is_spam:
          return False    # already correctly classified
--- 36,43 ----
      from spambayes.tokenizer import tokenize
  
!     if not mgr.message_db.has_key(msg.searchkey):
!         was_spam = None
!     else:
!         was_spam = mgr.message_db[msg.searchkey]=='1'
      if was_spam == is_spam:
          return False    # already correctly classified
***************
*** 48,52 ****
      # Learn the correct classification.
      mgr.bayes.learn(tokenize(stream), is_spam)
!     mgr.message_db[msg.searchkey] = is_spam
      mgr.bayes_dirty = True
  
--- 51,55 ----
      # Learn the correct classification.
      mgr.bayes.learn(tokenize(stream), is_spam)
!     mgr.message_db[msg.searchkey] = ['0', '1'][is_spam]
      mgr.bayes_dirty = True
  





More information about the Spambayes-checkins mailing list