def METHOD_NAME(self, text):
    # run pre-categorization hook on text
    text = self.pre_categorize(text)
    types = set()
    return_val = defaultdict(set)
    for rule in self.rules:
        attrs = rule.match(text)
        # matched if attrs is not None - empty attr dict means a match
        if attrs is not None:
            # add types, rule attrs and matched attrs
            types |= rule.types
            # Also add its specified attrs.
            for k, v in attrs.items():
                return_val[k].add(v)
            return_val.update(**rule.attrs)
            # break if there was a match and rule says so, otherwise
            # continue testing against other rules
            if rule.stop:
                break
    # set type
    return_val["classification"] = list(types)
    # run post-categorize hook
    return_val = self.post_categorize(return_val)
    return self.finalize(return_val)