'Map tokens into a feature representation, implemented as a
{hashable: int} dict. If the features change, a new model must be
trained.'

def _get_features(self, i, word, context, prev, prev2):

    def add(name, *args):
        features['    '.join(((name,) + tuple(args)))] += 1
    i += len(self.START)
    features = defaultdict(int)
    add('bias')
    add('i    suffix', word[(-3):])
    add('i    pref1', word[0])
    add('i-1    tag', prev)
    add('i-2    tag', prev2)
    add('i    tag+i-2    tag', prev, prev2)
    add('i    word', context[i])
    add('i-1    tag+i    word', prev, context[i])
    add('i-1    word', context[(i - 1)])
    add('i-1    suffix', context[(i - 1)][(-3):])
    add('i-2    word', context[(i - 2)])
    add('i+1    word', context[(i + 1)])
    add('i+1    suffix', context[(i + 1)][(-3):])
    add('i+2    word', context[(i + 2)])
    return features
