def get_window_token(token, n=1, left=True, right=True):
    """Get a Span of a window of text containing a token.
    Args:
        n (int): Number of tokens on each side of token to return.
            Default 1.
        left (bool): Whether to include the span preceding token.
            Default True.
        right (bool): Whether to include the span following token.
            Default True.
    Returns:
        a spaCy Span
    """
    if left:
        start = max((token.i-n, 0))
    else:
        start = token.i
    if right:
        end = min((token.i+n+1, len(token.doc)))
    else:
        end = token.i+1
    return token.doc[start:end]