def compilePatterns(self):
for text, score, match in self.regexs:
self.debug("Add regex pattern: %r" % text)
yield (text, score, match)
for text, score in self.patterns.iteritems():
regex = r'%s' % re.escape(text.lower())
self.debug("Create pattern regex: %r" % regex)
match = re.compile(regex, re.IGNORECASE).search
yield (text, score, match)
for text, score in self.words.iteritems():
regex = r'(?:^|\W)%s(?:$|\W)' % re.escape(text.lower())
self.debug("Create word regex: %r" % regex)
match = re.compile(regex, re.IGNORECASE).search
yield (text, score, match)
评论列表
文章目录