class documentation

A feature encoding that calls a user-supplied function to map a given featureset/label pair to a sparse joint-feature vector.

Method __init__ Construct a new feature encoding based on the given function.
Method describe :return: A string describing the value of the joint-feature whose index in the generated feature vectors is ``fid``. :rtype: str
Method encode Given a (featureset, label) pair, return the corresponding vector of joint-feature values. This vector is represented as a list of ``(index, value)`` tuples, specifying the value of each non-zero joint-feature.
Method labels :return: A list of the "known labels" -- i.e., all labels ``l`` such that ``self.encode(fs,l)`` can be a nonzero joint-feature vector for some value of ``fs``. :rtype: list
Method length :return: The size of the fixed-length joint-feature vectors that are generated by this encoding. :rtype: int
Instance Variable _func Undocumented
Instance Variable _labels Undocumented
Instance Variable _length Undocumented

Inherited from MaxentFeatureEncodingI:

Method train Construct and return new feature encoding, based on a given training corpus ``train_toks``.
def __init__(self, func, length, labels): (source)

Construct a new feature encoding based on the given function. :type func: (callable) :param func: A function that takes two arguments, a featureset and a label, and returns the sparse joint feature vector that encodes them:: func(featureset, label) -> feature_vector This sparse joint feature vector (``feature_vector``) is a list of ``(index,value)`` tuples. :type length: int :param length: The size of the fixed-length joint-feature vectors that are generated by this encoding. :type labels: list :param labels: A list of the "known labels" for this encoding -- i.e., all labels ``l`` such that ``self.encode(fs,l)`` can be a nonzero joint-feature vector for some value of ``fs``.

def describe(self, fid): (source)

:return: A string describing the value of the joint-feature whose index in the generated feature vectors is ``fid``. :rtype: str

def encode(self, featureset, label): (source)

Given a (featureset, label) pair, return the corresponding vector of joint-feature values. This vector is represented as a list of ``(index, value)`` tuples, specifying the value of each non-zero joint-feature.

:type featureset: dict :rtype: list(tuple(int, int))

def labels(self): (source)

:return: A list of the "known labels" -- i.e., all labels ``l`` such that ``self.encode(fs,l)`` can be a nonzero joint-feature vector for some value of ``fs``. :rtype: list

def length(self): (source)

:return: The size of the fixed-length joint-feature vectors that are generated by this encoding. :rtype: int

Undocumented

Undocumented

Undocumented