A mapping from feature identifiers to feature values, where each
feature value is either a basic value (such as a string or an integer),
or a nested feature structure. There are two types of feature
structure:
Feature structures may be indexed using either simple feature
identifiers or 'feature paths.' A feature path is a sequence of feature identifiers
that stand for a corresponding sequence of indexing operations. In
particular, fstruct[(f1,f2,...,fn)]
is equivalent to
fstruct[f1][f2]...[fn]
.
Feature structures may contain reentrant feature structures. A reentrant feature structure is a single feature
structure object that can be accessed via multiple feature paths.
Feature structures may also be cyclic. A feature structure is cyclic if there is any
feature path from the feature structure to itself.
Two feature structures are considered equal if they assign the same
values to all features, and have the same reentrances.
By default, feature structures are mutable. They may be made
immutable with the freeze() function. Once they have been frozen, they may
be hashed, and thus used as dictionary keys.
Inherited from object :
__delattr__ ,
__getattribute__ ,
__init__ ,
__reduce__ ,
__reduce_ex__ ,
__setattr__ ,
__str__
|
|
_keys(self)
Return an iterable of the feature identifiers used by this
FeatStruct. |
source code
|
|
|
_values(self)
Return an iterable of the feature values directly defined by this
FeatStruct. |
source code
|
|
|
_items(self)
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. |
source code
|
|
|
equal_values(self,
other,
check_reentrance=False)
Returns:
True if self and other assign the same
value to to every feature. |
source code
|
|
|
__eq__(self,
other)
Return true if self and other are both
feature structures, assign the same values to all features, and
contain the same reentrances. |
source code
|
|
|
__ne__(self,
other)
Return true unless self and other are both
feature structures, assign the same values to all features, and
contain the same reentrances. |
source code
|
|
|
__hash__(self)
If this feature structure is frozen, return its hash value;
otherwise, raise TypeError . |
source code
|
|
|
_equal(self,
other,
check_reentrance,
visited_self,
visited_other,
visited_pairs)
Returns:
True iff self and other have equal values. |
source code
|
|
|
_hash(self,
visited)
Returns:
A hash value for this feature structure. |
source code
|
|
|
freeze(self)
Make this feature structure, and any feature structures it contains,
immutable. |
source code
|
|
|
|
|
_freeze(self,
visited)
Make this feature structure, and any feature structure it contains,
immutable. |
source code
|
|
|
|
|
|
|
|
list of FeatStruct
|
reentrances(self)
Returns:
A list of all feature structures that can be reached from
self by multiple feature paths. |
source code
|
|
|
walk(self)
Return an iterator that generates this feature structure, and each
feature structure it contains. |
source code
|
|
|
|
|
_find_reentrances(self,
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. |
source code
|
|
(any)
|
|
|
|
|
|
|
|
FeatStruct
|
|
|
unify(self,
other,
bindings=None,
trace=False,
fail=None,
rename_vars=True) |
source code
|
|
|
|
|
__repr__(self)
Display a single-line representation of this feature structure,
suitable for embedding in other representations. |
source code
|
|
|
_repr(self,
reentrances,
reentrance_ids)
Returns:
A string representation of this feature structure. |
source code
|
|