nltk.FeatStruct

class nltk.FeatStruct[source]

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 dictionaries, implemented by FeatDict, act like Python dictionaries. Feature identifiers may be strings or instances of the Feature class.
  • feature lists, implemented by FeatList, act like Python lists. Feature identifiers are integers.

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 reentrancies.

By default, feature structures are mutable. They may be made immutable with the freeze() method. Once they have been frozen, they may be hashed, and thus used as dictionary keys.

Methods

copy([deep]) Return a new copy of self.
cyclic() Return True if this feature structure contains itself.
equal_values(other[, check_reentrance]) Return True if self and other assign the same value to to every feature.
freeze() Make this feature structure, and any feature structures it contains, immutable.
frozen() Return True if this feature structure is immutable.
remove_variables() Return the feature structure that is obtained by deleting any feature whose value is a Variable.
rename_variables([vars, used_vars, new_vars])
see:nltk.featstruct.rename_variables()
retract_bindings(bindings)
see:nltk.featstruct.retract_bindings()
substitute_bindings(bindings)
see:nltk.featstruct.substitute_bindings()
subsumes(other) Return True if self subsumes other.
unify(other[, bindings, trace, fail, ...])
variables()
see:nltk.featstruct.find_variables()
walk() Return an iterator that generates this feature structure, and each feature structure it contains.