def apply(self, tokens):
<EOL>i = <NUM_LIT:0><EOL>while i < len(tokens):<EOL><INDENT>w = tokens[i][<NUM_LIT:0>].lower()<EOL>if RE_ENTITY1.match(w)or RE_ENTITY2.match(w)or RE_ENTITY3.match(w):<EOL><INDENT>tokens[i][<NUM_LIT:1>] = self.tag<EOL><DEDENT>if w in self:<EOL><INDENT>for e in self[w]:<EOL><INDENT>e, tag = (e[:-<NUM_LIT:1>], "<STR_LIT:->"+e[-<NUM_LIT:1>].upper()) if e[-<NUM_LIT:1>] in self._cmd else (e, "<STR_LIT>")<EOL>b = True<EOL>for j, e in enumerate(e):<EOL><INDENT>if i + j >= len(tokens) or tokens[i+j][<NUM_LIT:0>].lower() != e:<EOL><INDENT>b = False; break<EOL><DEDENT><DEDENT>if b:<EOL><INDENT>for token in tokens[i:i+j+<NUM_LIT:1>]:<EOL><INDENT>token[<NUM_LIT:1>] = token[<NUM_LIT:1>] if token[<NUM_LIT:1>].startswith(self.tag) else self.tag<EOL>token[<NUM_LIT:1>] += tag<EOL><DEDENT>i += j<EOL>break<EOL><DEDENT><DEDENT><DEDENT>i += <NUM_LIT:1><EOL><DEDENT>return tokens<EOL>
Applies the named entity recognizer to the given list of tokens,
            where each token is a [word, tag] list.