gatenlp.feature_bearer module — GATE NLP library (gatenlp) documentation

# gatenlp.feature_bearer module

A “mixin” class to use for classes which should have features. This turns the class into something that can be used much like a dict in addition to original methods of the class. The inheriting class must implement _log_feature_change(command, feature=None, value=None) and must have an attribute changelog.

class `gatenlp.feature_bearer.` `FeatureBearer`(initialfeatures=None)

  Bases: `object`

  Initialise any features, if necessary. :param initialfeatures: an iterable containing tuples of initial feature key/value pairs :return:

  `clear_features`() → None

    Remove all features. :return:

  `copy`() → Dict

    Return a shallow copy of the feature map. This is NOT a view and does not update when the features change! :return:

  `del_feature`(featurename: str) → None

    Remove the feature with that name :param featurename: the feature to remove from the set :return:

  `feature_names`() → Union[Set, KeysView]

    Return an iterable with the feature names. This is NOT a view and does not update when the features change! :return:

  `feature_values`() → List

    Return an iterable with the feature values. This is NOT a view and does not update when the features change! :return:

  `get_feature`(key: str, default=None)
  `has_feature`(key: str) → bool
  `num_features`() → int

    Return the number of features. We do not use “len” for this, since the feature bearing object may have its own useful len implementation. :return: number of features

  `set_feature`(key: str, value) → None

    Set feature to the given value :param key: feature name :param value: value :return:

  `update_features`(*other, **kwargs)

    Update the features from another map or an iterable of key value pairs or from keyword arguments :param other: another dictionary or an iterable of key,value pairs :param kwargs: used to update the features :return:

class `gatenlp.feature_bearer.` `FeatureViewer`(features, changelog=None, logger=None)

  Bases: `gatenlp.feature_bearer.FeatureBearer`

  Initialise any features, if necessary. :param initialfeatures: an iterable containing tuples of initial feature key/value pairs :return: