'Checks which known patterns match the message.
Given a sentence, returns a vector of {1,0} values indicating which regexes did match. Furthermore, if the
message is tokenized, the function will mark the matching regex on the tokens that are part of the match.'

def features_for_patterns(self, message):

    import numpy as np
    found = []
    for (i, exp) in enumerate(self.known_patterns):
        match = re.search(exp[u'pattern'], message.text)
        if (match is not None):
            for t in message.get(u'tokens', []):
                if ((t.offset < match.end()) and (t.end > match.start())):
                    t.set(u'pattern', i)
            found.append(1.0)
        else:
            found.append(0.0)
    return np.array(found)
