[Spambayes-checkins] spambayes Options.py,NONE,1.1
README.txt,1.12,1.13
Tim Peters
tim_one@users.sourceforge.net
Mon, 09 Sep 2002 09:19:41 -0700
Update of /cvsroot/spambayes/spambayes
In directory usw-pr-cvs1:/tmp/cvs-serv20464
Modified Files:
README.txt
Added Files:
Options.py
Log Message:
Options.options is intended to be shared global state, for customizing
what the classifier and tokenizer do in a controlled and reportable
way (note that options.display() produces a nice string spelling out the
options in effect). Nothing uses this yet.
--- NEW FILE: Options.py ---
from sets import Set
# Descriptions of options.
# Empty lines, and lines starting with a blank, are ignored.
# A line starting with a non-blank character is of the form:
# option_name "default" default_value
# option_name must not contain whitespace
# default_value must be eval'able.
option_descriptions = """
retain_pure_html_tags default False
By default, HTML tags are stripped from pure text/html messages.
Set retain_pure_html_tags True to retain HTML tags in this case.
"""
class OptionsClass(dict):
def __init__(self):
self.optnames = Set()
for line in option_descriptions.split('\n'):
if not line or line.startswith(' '):
continue
i = line.index(' ')
name = line[:i]
self.optnames.add(name)
i = line.index(' default ', i)
self.setopt(name, eval(line[i+9:], {}))
def _checkname(self, name):
if name not in self.optnames:
raise KeyError("there's no option named %r" % name)
def setopt(self, name, value):
self._checkname(name)
self[name] = value
def display(self):
"""Return a string showing current option values."""
result = ['Option values:\n']
width = max([len(name) for name in self.keys()])
items = self.items()
items.sort()
for name, value in items:
result.append(' %-*s: %r\n' % (width, name, value))
return ''.join(result)
options = OptionsClass()
Index: README.txt
===================================================================
RCS file: /cvsroot/spambayes/spambayes/README.txt,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** README.txt 8 Sep 2002 23:53:23 -0000 1.12
--- README.txt 9 Sep 2002 16:19:39 -0000 1.13
***************
*** 22,25 ****
--- 22,32 ----
Primary Files
=============
+ Options.py
+ A start at a flexible way to control what the tokenizer and
+ classifier do. Different people are finding different ways in
+ which their test data is biased, and so fiddle the code to
+ worm around that. It's become almost impossible to know
+ exactly what someone did when they report results.
+
classifier.py
An implementation of a Graham-like classifier.