[Python-checkins] r68654 - in tracker/instances/spambayes_integration: detectors/spambayes.py extensions/spambayes.py
martin.v.loewis
python-checkins at python.org
Sat Jan 17 12:36:36 CET 2009
Author: martin.v.loewis
Date: Sat Jan 17 12:36:35 2009
New Revision: 68654
Log:
Issue 215: add hasrev token.
Modified:
tracker/instances/spambayes_integration/detectors/spambayes.py
tracker/instances/spambayes_integration/extensions/spambayes.py
Modified: tracker/instances/spambayes_integration/detectors/spambayes.py
==============================================================================
--- tracker/instances/spambayes_integration/detectors/spambayes.py (original)
+++ tracker/instances/spambayes_integration/detectors/spambayes.py Sat Jan 17 12:36:35 2009
@@ -3,9 +3,12 @@
import socket
import time
import math
+import re
from roundup.exceptions import Reject
+REVPAT = re.compile(r'(r[0-9]+\b|rev(ision)? [0-9]+\b)')
+
def extract_classinfo(db, klass, nodeid, newvalues):
if None == nodeid:
node = newvalues
@@ -28,7 +31,8 @@
tokens = ["klass:%s" % klass.classname,
"author:%s" % authorid,
- "authorage:%d" % int(math.log(authorage))]
+ "authorage:%d" % int(math.log(authorage)),
+ "hasrev:%s" % REVPAT.search(content) is not None]
return (content, tokens)
Modified: tracker/instances/spambayes_integration/extensions/spambayes.py
==============================================================================
--- tracker/instances/spambayes_integration/extensions/spambayes.py (original)
+++ tracker/instances/spambayes_integration/extensions/spambayes.py Sat Jan 17 12:36:35 2009
@@ -3,15 +3,20 @@
import xmlrpclib, socket
+REVPAT = re.compile(r'(r[0-9]+\b|rev(ision)? [0-9]+\b)')
+
def extract_classinfo(db, classname, nodeid):
node = db.getnode(classname, nodeid)
authorage = node['creation'].timestamp() - \
db.getnode('user', node.get('author', node.get('creator')))['creation'].timestamp()
+ authorid = node.get('author', node.get('creator')
+
tokens = ["klass:%s" % classname,
- "author:%s" % node.get('author', node.get('creator')),
- "authorage:%d" % int(authorage)]
+ "author:%s" % authorid,
+ "authorage:%d" % int(math.log(authorage)),
+ "hasrev:%s" % REVPAT.search(content) is not None]
klass = db.getclass(classname)
return (klass.get(nodeid, 'content'), tokens)
More information about the Python-checkins
mailing list