module documentation

Utility functions and classes for classifiers.

Class CutoffChecker A helper class that implements cutoff checks based on number of iterations and log likelihood.
Function accuracy Undocumented
Function apply_features Use the LazyMap class to construct a lazy list-like object that is analogous to map(feature_func, toks). In particular, if labeled=False, then the returned list-like object's values are equal to:
Function attested_labels No summary
Function binary_names_demo_features Undocumented
Function check_megam_config Checks whether the MEGAM binary is configured.
Function log_likelihood Undocumented
Function names_demo Undocumented
Function names_demo_features Undocumented
Function partial_names_demo Undocumented
Function wsd_demo Undocumented
Variable _inst_cache Undocumented
def accuracy(classifier, gold): (source)

Undocumented

def apply_features(feature_func, toks, labeled=None): (source)

Use the LazyMap class to construct a lazy list-like object that is analogous to map(feature_func, toks). In particular, if labeled=False, then the returned list-like object's values are equal to:

[feature_func(tok) for tok in toks]

If labeled=True, then the returned list-like object's values are equal to:

[(feature_func(tok), label) for (tok, label) in toks]

The primary purpose of this function is to avoid the memory overhead involved in storing all the featuresets for every token in a corpus. Instead, these featuresets are constructed lazily, as-needed. The reduction in memory overhead can be especially significant when the underlying list of tokens is itself lazy (as is the case with many corpus readers).

Parameters
feature_funcThe function that will be applied to each token. It should return a featureset -- i.e., a dict mapping feature names to feature values.
toksThe list of tokens to which feature_func should be applied. If labeled=True, then the list elements will be passed directly to feature_func(). If labeled=False, then the list elements should be tuples (tok,label), and tok will be passed to feature_func().
labeledIf true, then toks contains labeled tokens -- i.e., tuples of the form (tok, label). (Default: auto-detect based on types.)
def attested_labels(tokens): (source)
Parameters
tokens:listThe list of classified tokens from which to extract labels. A classified token has the form (token, label).
Returns
list of (immutable)A list of all labels that are attested in the given list of tokens.
def binary_names_demo_features(name): (source)

Undocumented

def check_megam_config(): (source)

Checks whether the MEGAM binary is configured.

def log_likelihood(classifier, gold): (source)

Undocumented

def names_demo(trainer, features=names_demo_features): (source)

Undocumented

def names_demo_features(name): (source)

Undocumented

def partial_names_demo(trainer, features=names_demo_features): (source)

Undocumented

def wsd_demo(trainer, word, features, n=1000): (source)

Undocumented

_inst_cache: dict = (source)

Undocumented