corpustools.neighdens.neighborhood_density.neighborhood_density(corpus_context, query, tierdict, algorithm='edit_distance', max_distance=1, collapse_homophones=False, force_quadratic=False, file_type=None, tier_type=None, sequence_type=None, stop_check=None, call_back=None)[source]

Calculate the neighborhood density of a particular word in the corpus.

corpus_context : CorpusContext

Context manager for a corpus

query : Word

The word whose neighborhood density to calculate.

algorithm : str

The algorithm used to determine distance

max_distance : float, optional

Maximum edit distance from the queried word to consider a word a neighbor

force_quadratic : bool

Force use of the less efficient quadratic algorithm even when finding edit distance of 1 neighborhoods

stop_check : callable, optional

Optional function to check whether to gracefully terminate early

call_back : callable, optional

Optional function to supply progress information during the function

tuple(int, set)

Tuple of the number of neighbors and the set of neighbor Words.