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)[source]¶ Bases:
object
Initialise any features, if necessary. :param initialfeatures: an iterable containing tuples of initial feature key/value pairs :return:
-
copy
() → Dict[source]¶ 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[source]¶ Remove the feature with that name :param featurename: the feature to remove from the set :return:
-
feature_names
() → Union[Set, KeysView][source]¶ Return an iterable with the feature names. This is NOT a view and does not update when the features change! :return:
-
feature_values
() → List[source]¶ Return an iterable with the feature values. This is NOT a view and does not update when the features change! :return:
-
num_features
() → int[source]¶ 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
-
-
class
gatenlp.feature_bearer.
FeatureViewer
(features, changelog=None, logger=None)[source]¶ Bases:
gatenlp.feature_bearer.FeatureBearer
Initialise any features, if necessary. :param initialfeatures: an iterable containing tuples of initial feature key/value pairs :return: