calc_prod

corpustools.prod.pred_of_dist.calc_prod(corpus_context, envs, strict=True, all_info=False, stop_check=None, call_back=None)[source]

Main function for calculating predictability of distribution for two segments over specified environments in a corpus.

Parameters:

corpus_context : CorpusContext

Context manager for a corpus

envs : list of EnvironmentFilter

List of EnvironmentFilter objects that specify environments

strict : bool

If true, exceptions will be raised for non-exhausive environments and non-unique environments. If false, only warnings will be shown. Defaults to True.

all_info : bool

If true, all the intermediate numbers for calculating predictability of distribution will be returned. If false, only the final entropy will be returned. Defaults to False.

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

Returns:

dict

Keys are the environments specified and values are either a list of [entropy, frequency of environment, frequency of seg1, frequency of seg2] if all_info is True, or just entropy if all_info is False.