class documentation

A feature structure that acts like a Python dictionary. I.e., a mapping from feature identifiers to feature values, where a feature identifier can be a string or a Feature; and where a feature value can be either a basic value (such as a string or an integer), or a nested feature structure. A feature identifiers for a FeatDict is sometimes called a "feature name".

Two feature dicts are considered equal if they assign the same values to all features, and have the same reentrances.

See Also
FeatStruct for information about feature paths, reentrance, cyclic feature structures, mutability, freezing, and hashing.
Method __contains__ Return true if a feature with the given name or path exists.
Method __deepcopy__ Undocumented
Method __delitem__ If the feature with the given name or path exists, delete its value; otherwise, raise KeyError.
Method __getitem__ If the feature with the given name or path exists, return its value; otherwise, raise KeyError.
Method __init__ Create a new feature dictionary, with the specified features.
Method __setitem__ Set the value for the feature with the given name or path to value. If name_or_path is an invalid path, raise KeyError.
Method __str__ Display a multi-line representation of this feature dictionary as an FVM (feature value matrix).
Method get If the feature with the given name or path exists, return its value; otherwise, return default.
Method has_key Return true if a feature with the given name or path exists.
Method update Undocumented
Class Variable clear Undocumented
Class Variable pop Undocumented
Class Variable popitem Undocumented
Class Variable setdefault Undocumented
Method _items Return an iterable of (fid,fval) pairs, where fid is a feature identifier and fval is the corresponding feature value, for all features defined by this FeatStruct.
Method _keys Return an iterable of the feature identifiers used by this FeatStruct.
Method _repr Return a string representation of this feature structure.
Method _str No summary
Method _values Return an iterable of the feature values directly defined by this FeatStruct.
Constant _INDEX_ERROR Undocumented

Inherited from FeatStruct:

Method __eq__ Return true if self and other are both feature structures, assign the same values to all features, and contain the same reentrances. I.e., return self.equal_values(other, check_reentrance=True).
Method __hash__ If this feature structure is frozen, return its hash value; otherwise, raise TypeError.
Method __lt__ Undocumented
Method __ne__ Undocumented
Method __new__ Construct and return a new feature structure. If this constructor is called directly, then the returned feature structure will be an instance of either the FeatDict class or the FeatList class.
Method __repr__ Display a single-line representation of this feature structure, suitable for embedding in other representations.
Method copy Return a new copy of self. The new copy will not be frozen.
Method cyclic Return True if this feature structure contains itself.
Method equal_values Return True if self and other assign the same value to to every feature. In particular, return true if self[p]==other[p] for every feature path p such that self[p] or other[p] is a base value (i.e., not a nested feature structure).
Method freeze Make this feature structure, and any feature structures it contains, immutable. Note: this method does not attempt to 'freeze' any feature value that is not a FeatStruct; it is recommended that you use only immutable feature values.
Method frozen Return True if this feature structure is immutable. Feature structures can be made immutable with the freeze() method. Immutable feature structures may not be made mutable again, but new mutable copies can be produced with the ...
Method remove_variables Return the feature structure that is obtained by deleting any feature whose value is a Variable.
Method rename_variables No summary
Method retract_bindings No summary
Method substitute_bindings No summary
Method subsumes Return True if self subsumes other. I.e., return true If unifying self with other would result in a feature structure equal to other.
Method unify Undocumented
Method variables No summary
Method walk Return an iterator that generates this feature structure, and each feature structure it contains. Each feature structure will be generated exactly once.
Method _calculate_hashvalue Return a hash value for this feature structure.
Method _equal Return True iff self and other have equal values.
Method _find_reentrances Return a dictionary that maps from the id of each feature structure contained in self (including self) to a boolean value, indicating whether it is reentrant or not.
Method _freeze Make this feature structure, and any feature structure it contains, immutable.
Method _walk Undocumented
Constant _FROZEN_ERROR Undocumented
Instance Variable _frozen frozen or not. Once this flag is set, it should never be un-set; and no further modification should be made to this feature structue.
Instance Variable _hash Undocumented
def __contains__(self, name_or_path): (source)

Return true if a feature with the given name or path exists.

def __deepcopy__(self, memo): (source)
def __delitem__(self, name_or_path): (source)

If the feature with the given name or path exists, delete its value; otherwise, raise KeyError.

def __getitem__(self, name_or_path): (source)

If the feature with the given name or path exists, return its value; otherwise, raise KeyError.

def __init__(self, features=None, **morefeatures): (source)

Create a new feature dictionary, with the specified features.

Parameters
featuresThe initial value for this feature dictionary. If features is a FeatStruct, then its features are copied (shallow copy). If features is a dict, then a feature is created for each item, mapping its key to its value. If features is a string, then it is processed using FeatStructReader. If features is a list of tuples (name, val), then a feature is created for each tuple.
**morefeaturesAdditional features for the new feature dictionary. If a feature is listed under both features and morefeatures, then the value from morefeatures will be used.
def __setitem__(self, name_or_path, value): (source)

Set the value for the feature with the given name or path to value. If name_or_path is an invalid path, raise KeyError.

def __str__(self): (source)

Display a multi-line representation of this feature dictionary as an FVM (feature value matrix).

def get(self, name_or_path, default=None): (source)

If the feature with the given name or path exists, return its value; otherwise, return default.

def has_key(self, name_or_path): (source)

Return true if a feature with the given name or path exists.

def update(self, features=None, **morefeatures): (source)

Undocumented

Undocumented

Undocumented

Undocumented

setdefault = (source)

Undocumented

def _items(self): (source)

Return an iterable of (fid,fval) pairs, where fid is a feature identifier and fval is the corresponding feature value, for all features defined by this FeatStruct.

def _keys(self): (source)

Return an iterable of the feature identifiers used by this FeatStruct.

def _repr(self, reentrances, reentrance_ids): (source)

Return a string representation of this feature structure.

Parameters
reentrancesA dictionary that maps from the id of each feature value in self, indicating whether that value is reentrant or not.
reentrance_idsA dictionary mapping from each id of a feature value to a unique identifier. This is modified by repr: the first time a reentrant feature value is displayed, an identifier is added to reentrance_ids for it.
def _str(self, reentrances, reentrance_ids): (source)
Parameters
reentrancesA dictionary that maps from the id of each feature value in self, indicating whether that value is reentrant or not.
reentrance_idsA dictionary mapping from each id of a feature value to a unique identifier. This is modified by repr: the first time a reentrant feature value is displayed, an identifier is added to reentrance_ids for it.
Returns
A list of lines composing a string representation of this feature dictionary.
def _values(self): (source)

Return an iterable of the feature values directly defined by this FeatStruct.

_INDEX_ERROR = (source)

Undocumented

Value
str('Expected feature name or path.  Got %r.')