[Spambayes-checkins] spambayes/Outlook2000 default_bayes_customize.ini,1.1,1.2 manager.py,1.16,1.17

Tim Peters tim_one@users.sourceforge.net
Wed, 23 Oct 2002 21:58:54 -0700


Update of /cvsroot/spambayes/spambayes/Outlook2000
In directory usw-pr-cvs1:/tmp/cvs-serv20955

Modified Files:
	default_bayes_customize.ini manager.py 
Log Message:
Our (Outlook's) spambayes .ini file was ineffective, because the envar was
set too late to do any good.  Tried to repair that.


Index: default_bayes_customize.ini
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/default_bayes_customize.ini,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** default_bayes_customize.ini	19 Oct 2002 16:24:41 -0000	1.1
--- default_bayes_customize.ini	24 Oct 2002 04:58:52 -0000	1.2
***************
*** 2,3 ****
--- 2,6 ----
  # This file must exist, or the addin considers itself confused.
  # As we decide default options, we can add them!
+ 
+ [Classifier]
+ #use_chi_squared_combining: True

Index: manager.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/manager.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** manager.py	24 Oct 2002 04:22:19 -0000	1.16
--- manager.py	24 Oct 2002 04:58:52 -0000	1.17
***************
*** 17,32 ****
      this_filename = os.path.abspath(sys.argv[0])
  
! # This is a little of a hack <wink>.  We are generally in a child directory of the
! # bayes code.  To help installation, we handle the fact that this may not be
! # on sys.path.
! try:
!     import classifier
! except ImportError:
!     parent = os.path.abspath(os.path.join(os.path.dirname(this_filename), ".."))
!     sys.path.insert(0, parent)
!     del parent
!     import classifier
  
! from tokenizer import tokenize
  
  # Suck in CDO type lib
--- 17,40 ----
      this_filename = os.path.abspath(sys.argv[0])
  
! # This is a little bit of a hack <wink>.  We are generally in a child directory
! # of the bayes code.  To help installation, we handle the fact that this may
! # not be on sys.path.  Note that doing these imports is delayed, so that we
! # can set the BAYESCUSTOMIZE envar first (if we import anything from the core
! # spambayes code before setting that envar, our .ini file may have no effect).
! def import_core_spambayes_stuff(ini_filename):
!     global bayes_classifier, bayes_tokenize
  
!     os.environ["BAYESCUSTOMIZE"] = ini_filename
!     try:
!         import classifier
!     except ImportError:
!         parent = os.path.abspath(os.path.join(os.path.dirname(this_filename),
!                                               ".."))
!         sys.path.insert(0, parent)
! 
!     import classifier
!     from tokenizer import tokenize
!     bayes_classifier = classifier
!     bayes_tokenize = tokenize
  
  # Suck in CDO type lib
***************
*** 60,63 ****
--- 68,72 ----
          os.chdir(cwd)
  
+         import_core_spambayes_stuff(self.ini_filename)
          self.LoadBayes()
  
***************
*** 114,119 ****
          bayes = None
          try:
!             os.environ["BAYESCUSTOMIZE"]=self.ini_filename
!             bayes = cPickle.load(open(self.bayes_filename,'rb'))
              print "Loaded bayes database from '%s'" % (self.bayes_filename,)
          except IOError:
--- 123,127 ----
          bayes = None
          try:
!             bayes = cPickle.load(open(self.bayes_filename, 'rb'))
              print "Loaded bayes database from '%s'" % (self.bayes_filename,)
          except IOError:
***************
*** 161,166 ****
  
      def InitNewBayes(self):
!         os.environ["BAYESCUSTOMIZE"]=self.ini_filename
!         self.bayes = classifier.Bayes()
          self.bayes_dirty = True
  
--- 169,173 ----
  
      def InitNewBayes(self):
!         self.bayes = bayes_classifier.Bayes()
          self.bayes_dirty = True
  
***************
*** 228,232 ****
  
      def score(self, msg, evidence=False):
!         return self.bayes.spamprob(tokenize(msg), evidence)
  
  _mgr = None
--- 235,239 ----
  
      def score(self, msg, evidence=False):
!         return self.bayes.spamprob(bayes_tokenize(msg), evidence)
  
  _mgr = None