def find_tags(tokens, lexicon={}, model=None, morphology=None, context=None, entities=None, default=("<STR_LIT>", "<STR_LIT>", "<STR_LIT>"), language="<STR_LIT>", map=None, **kwargs):
tagged = []<EOL>for i, token in enumerate(tokens):<EOL><INDENT>tagged.append([token, lexicon.get(token, i == <NUM_LIT:0> and lexicon.get(token.lower()) or None)])<EOL><DEDENT>for i, (token, tag) in enumerate(tagged):<EOL><INDENT>prev, next = (None, None), (None, None)<EOL>if i > <NUM_LIT:0>:<EOL><INDENT>prev = tagged[i-<NUM_LIT:1>]<EOL><DEDENT>if i < len(tagged) - <NUM_LIT:1>:<EOL><INDENT>next = tagged[i+<NUM_LIT:1>]<EOL><DEDENT>if tag is None or token in (model is not None and model.unknown or ()):<EOL><INDENT>if model is not None:<EOL><INDENT>tagged[i] = model.apply([token, None], prev, next)<EOL><DEDENT>elif token.istitle() and language != "<STR_LIT>":<EOL><INDENT>tagged[i] = [token, default[<NUM_LIT:1>]]<EOL><DEDENT>elif CD.match(token) is not None:<EOL><INDENT>tagged[i] = [token, default[<NUM_LIT:2>]]<EOL><DEDENT>elif morphology is not None:<EOL><INDENT>tagged[i] = morphology.apply([token, default[<NUM_LIT:0>]], prev, next)<EOL><DEDENT>elif language == "<STR_LIT>":<EOL><INDENT>tagged[i] = _suffix_rules([token, default[<NUM_LIT:0>]])<EOL><DEDENT>else:<EOL><INDENT>tagged[i] = [token, default[<NUM_LIT:0>]]<EOL><DEDENT><DEDENT><DEDENT>if context is not None and model is None:<EOL><INDENT>tagged = context.apply(tagged)<EOL><DEDENT>if entities is not None:<EOL><INDENT>tagged = entities.apply(tagged)<EOL><DEDENT>if map is not None:<EOL><INDENT>tagged = [list(map(token, tag)) or [token, default[<NUM_LIT:0>]] for token, tag in tagged]<EOL><DEDENT>return tagged<EOL>
Returns a list of [token, tag]-items for the given list of tokens:
        ["The", "cat", "purs"] => [["The", "DT"], ["cat", "NN"], ["purs", "VB"]]
        Words are tagged using the given lexicon of (word, tag)-items.
        Unknown words are tagged NN by default.
        Unknown words that start with a capital letter are tagged NNP (unless language="de").
        Unknown words that consist only of digits and punctuation marks are tagged CD.
        Unknown words are then improved with morphological rules.
        All words are improved with contextual rules.
        If a model is given, uses model for unknown words instead of morphology and context.
        If map is a function, it is applied to each (token, tag) after applying all rules.