':param labels: A list of the "known labels" for this encoding.
:param mapping: A dictionary mapping from ``(fname,fval,label)``
tuples to corresponding joint-feature indexes.  These
indexes must be the set of integers from 0...len(mapping).
If ``mapping[fname,fval,label]=id``, then
``self.encode(..., fname:fval, ..., label)[id]`` is 1;
otherwise, it is 0.
:param unseen_features: If true, then include unseen value
features in the generated joint-feature vectors.
:param alwayson_features: If true, then include always-on
features in the generated joint-feature vectors.'

def __init__(self, labels, mapping, unseen_features=False, alwayson_features=False):

    if (set(mapping.values()) != set(range(len(mapping)))):
        raise ValueError(u'Mapping    values    must    be    exactly    the    set    of    integers    from    0...len(mapping)')
    self._labels = list(labels)
    u'A    list    of    attested    labels.'
    self._mapping = mapping
    u'dict    mapping    from    (fname,fval,label)    ->    fid'
    self._length = len(mapping)
    u'The    length    of    generated    joint    feature    vectors.'
    self._alwayson = None
    u'dict    mapping    from    label    ->    fid'
    self._unseen = None
    u'dict    mapping    from    fname    ->    fid'
    if alwayson_features:
        self._alwayson = dict(((label, (i + self._length)) for (i, label) in enumerate(labels)))
        self._length += len(self._alwayson)
    if unseen_features:
        fnames = set((fname for (fname, fval, label) in mapping))
        self._unseen = dict(((fname, (i + self._length)) for (i, fname) in enumerate(fnames)))
        self._length += len(fnames)
