neighborhood_density

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.

Parameters
corpus_contextCorpusContext

Context manager for a corpus

queryWord

The word whose neighborhood density to calculate.

algorithmstr

The algorithm used to determine distance

max_distancefloat, optional

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

force_quadraticbool

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

stop_checkcallable, optional

Optional function to check whether to gracefully terminate early

call_backcallable, optional

Optional function to supply progress information during the function

Returns
tuple(int, set)

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