KullbackLeibler

corpustools.kl.kl.KullbackLeibler(corpus_context, seg1, seg2, side, outfile=None, stop_check=False, call_back=False)[source]

Calculates KL distances between two Phoneme objects in some context, either the left or right-hand side. Segments with identical distributions (ie. seg1==seg2) have a KL of zero. Segments with similar distributions therefore have low numbers, so high numbers indicate possible allophones.

Parameters
corpus_contextCorpusContext

Context manager for a corpus

seg1str

First segment

seg2str

Second segment

sidestr

One of ‘right’, ‘left’ or ‘both’

outfilestr

Full path to save output

stop_checkcallable or None

Optional function to check whether to gracefully terminate early

call_backcallable or None

Optional function to supply progress information during the function