def get_neighbor_cell_ngrams(<EOL>mention, dist=<NUM_LIT:1>, directions=False, attrib="<STR_LIT>", n_min=<NUM_LIT:1>, n_max=<NUM_LIT:1>, lower=True<EOL>):
<EOL>spans = _to_spans(mention)<EOL>for span in spans:<EOL><INDENT>for ngram in get_sentence_ngrams(<EOL>span, attrib=attrib, n_min=n_min, n_max=n_max, lower=lower<EOL>):<EOL><INDENT>yield ngram<EOL><DEDENT>if span.sentence.is_tabular():<EOL><INDENT>root_cell = span.sentence.cell<EOL>for sentence in chain.from_iterable(<EOL>[<EOL>_get_aligned_sentences(root_cell, "<STR_LIT>"),<EOL>_get_aligned_sentences(root_cell, "<STR_LIT>"),<EOL>]<EOL>):<EOL><INDENT>row_diff = min_row_diff(sentence, root_cell, absolute=False)<EOL>col_diff = min_col_diff(sentence, root_cell, absolute=False)<EOL>if (<EOL>(row_diff or col_diff)<EOL>and not (row_diff and col_diff)<EOL>and abs(row_diff) + abs(col_diff) <= dist<EOL>):<EOL><INDENT>if directions:<EOL><INDENT>direction = "<STR_LIT>"<EOL>if col_diff == <NUM_LIT:0>:<EOL><INDENT>if <NUM_LIT:0> < row_diff and row_diff <= dist:<EOL><INDENT>direction = "<STR_LIT>"<EOL><DEDENT>elif <NUM_LIT:0> > row_diff and row_diff >= -dist:<EOL><INDENT>direction = "<STR_LIT>"<EOL><DEDENT><DEDENT>elif row_diff == <NUM_LIT:0>:<EOL><INDENT>if <NUM_LIT:0> < col_diff and col_diff <= dist:<EOL><INDENT>direction = "<STR_LIT>"<EOL><DEDENT>elif <NUM_LIT:0> > col_diff and col_diff >= -dist:<EOL><INDENT>direction = "<STR_LIT>"<EOL><DEDENT><DEDENT>for ngram in tokens_to_ngrams(<EOL>getattr(sentence, attrib),<EOL>n_min=n_min,<EOL>n_max=n_max,<EOL>lower=lower,<EOL>):<EOL><INDENT>yield (ngram, direction)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>for ngram in tokens_to_ngrams(<EOL>getattr(sentence, attrib),<EOL>n_min=n_min,<EOL>n_max=n_max,<EOL>lower=lower,<EOL>):<EOL><INDENT>yield ngram<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>
Get the ngrams from all Cells that are within a given Cell distance in one
direction from the given Mention.

Note that if a candidate is passed in, all of its Mentions will be
searched. If `directions=True``, each ngram will be returned with a
direction in {'UP', 'DOWN', 'LEFT', 'RIGHT'}.

:param mention: The Mention whose neighbor Cells are being searched
:param dist: The Cell distance within which a neighbor Cell must be to be
    considered
:param directions: A Boolean expressing whether or not to return the
    direction of each ngram
:param attrib: The token attribute type (e.g. words, lemmas, poses)
:param n_min: The minimum n of the ngrams that should be returned
:param n_max: The maximum n of the ngrams that should be returned
:param lower: If True, all ngrams will be returned in lower case
:rtype: a *generator* of ngrams (or (ngram, direction) tuples if directions=True)