'Applies lexical rules to the given token, which is a [word, tag] list.'

def apply(self, token, previous=(None, None), next=(None, None)):

    w = token[0]
    for r in self:
        if (r[1] in self.cmd):
            (f, x, pos, cmd) = (bool(0), r[0], r[(-2)], r[1].lower())
        if (r[2] in self.cmd):
            (f, x, pos, cmd) = (bool(1), r[1], r[(-2)], r[2].lower().lstrip(u'f'))
        if (f and (token[1] != r[0])):
            continue
        if (((cmd == u'char') and (x in w)) or ((cmd == u'haspref') and w.startswith(x)) or ((cmd == u'hassuf') and w.endswith(x)) or ((cmd == u'addpref') and ((x + w) in self.lexicon)) or ((cmd == u'addsuf') and ((w + x) in self.lexicon)) or ((cmd == u'deletepref') and w.startswith(x) and (w[len(x):] in self.lexicon)) or ((cmd == u'deletesuf') and w.endswith(x) and (w[:(- len(x))] in self.lexicon)) or ((cmd == u'goodleft') and (x == next[0])) or ((cmd == u'goodright') and (x == previous[0]))):
            token[1] = pos
    return token
