def char2features(sentence, i):
char = sentence[i]<EOL>length = len(sentence)<EOL>features = [<EOL>'<STR_LIT>'.format(char.lower()),<EOL>'<STR_LIT>'.format(char.isupper()),<EOL>'<STR_LIT>'.format(char.isnumeric()),<EOL>]<EOL>if i == <NUM_LIT:0>:<EOL><INDENT>features.extend(['<STR_LIT>'])<EOL><DEDENT>if i > <NUM_LIT:0>:<EOL><INDENT>char = sentence[i - <NUM_LIT:1>]<EOL>features.extend([<EOL>'<STR_LIT>'.format(char.lower()),<EOL>'<STR_LIT>'.format(char.isupper()),<EOL>'<STR_LIT>'.format(char.isnumeric()),<EOL>])<EOL><DEDENT>if i > <NUM_LIT:1>:<EOL><INDENT>char = sentence[i - <NUM_LIT:2>]<EOL>features.extend([<EOL>'<STR_LIT>'.format(char.lower()),<EOL>'<STR_LIT>'.format(char.isupper()),<EOL>'<STR_LIT>'.format(char.isnumeric()),<EOL>])<EOL><DEDENT>if i < length - <NUM_LIT:1>:<EOL><INDENT>char = sentence[i + <NUM_LIT:1>]<EOL>features.extend([<EOL>'<STR_LIT>'.format(char.lower()),<EOL>'<STR_LIT>'.format(char.isupper()),<EOL>'<STR_LIT>'.format(char.isnumeric()),<EOL>])<EOL><DEDENT>if i < length - <NUM_LIT:2>:<EOL><INDENT>char = sentence[i + <NUM_LIT:2>]<EOL>features.extend([<EOL>'<STR_LIT>'.format(char.lower()),<EOL>'<STR_LIT>'.format(char.isupper()),<EOL>'<STR_LIT>'.format(char.isnumeric()),<EOL>])<EOL><DEDENT>if i == length - <NUM_LIT:1>:<EOL><INDENT>features.extend(['<STR_LIT>'])<EOL><DEDENT>return features<EOL>
Returns features of char at position `i` in given sentence
When it possible, result features list also includes features for 2 characters
ahead and behind current position (like bigrams, or something like it)
Currently, used features is:
1. lower-cased value of character
2. result of calling `character.isupper()` method
3. result of calling `character.isnumeric()` method