'Returns a training vector for the given token and its context.'

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

    def f(v, *s):
        v['    '.join(s)] = 1
    (p, n) = (previous, next)
    p = (('', '') if (not p) else ((p[0] or ''), (p[1] or '')))
    n = (('', '') if (not n) else ((n[0] or ''), (n[1] or '')))
    v = {}
    f(v, 'b', '    ')
    f(v, 'h', token[:1])
    f(v, 'w', (token[(-6):] if ((token not in self.known) or (token in self.unknown)) else ''))
    f(v, 'x', token[(-3):])
    f(v, '-x', p[0][(-3):])
    f(v, '+x', n[0][(-3):])
    f(v, '-t', p[1])
    f(v, '-+', (p[1] + n[1]))
    f(v, '+t', n[1])
    return v
