Package nltk :: Module featstruct :: Class FeatList
[hide private]
[frames] | no frames]

Class FeatList

source code

                   object --+        
                            |        
sem.logic.SubstituteBindingsI --+    
                                |    
                       FeatStruct --+
                                    |
                       object --+   |
                                |   |
                             list --+
                                    |
                                   FeatList

A list of feature values, where each feature value is either a basic value (such as a string or an integer), or a nested feature structure.

Feature lists may contain reentrant feature values. A reentrant feature value is a single feature value that can be accessed via multiple feature paths. Feature lists may also be cyclic.

Two feature lists 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.

Instance Methods [hide private]
new list
__init__(self, features=())
Create a new feature list, with the specified features.
source code

Inherited from list: __add__, __contains__, __ge__, __getattribute__, __getslice__, __gt__, __iter__, __le__, __len__, __lt__, __mul__, __reversed__, __rmul__, count, index

Inherited from object: __delattr__, __reduce__, __reduce_ex__, __setattr__, __str__

    List methods
 
__getitem__(self, name_or_path)
x[y]
source code
 
__delitem__(self, name_or_path)
If the feature with the given name or path exists, delete its value; otherwise, raise KeyError.
source code
 
__setitem__(self, name_or_path, value)
Set the value for the feature with the given name or path to value.
source code
 
__delslice__(x, i, j)
del x[i:j]
source code
 
__setslice__(x, i, j, y)
x[i:j]=y
source code
 
__iadd__(x, y)
x+=y If self is frozen, raise ValueError.
source code
 
__imul__(x, y)
x*=y If self is frozen, raise ValueError.
source code
 
append(L, object)
append object to end If self is frozen, raise ValueError.
source code
 
extend(L, iterable)
extend list by appending elements from the iterable If self is frozen, raise ValueError.
source code
 
insert(L, index, object)
insert object before index If self is frozen, raise ValueError.
source code
item
pop(L, index=...)
remove and return item at index (default last) If self is frozen, raise ValueError.
source code
 
remove(L, value)
remove first occurrence of value If self is frozen, raise ValueError.
source code
 
reverse(L)
reverse *IN PLACE* If self is frozen, raise ValueError.
source code
 
sort(L, cmp=None, key=None, reverse=False)
stable sort *IN PLACE*; cmp(x, y) -> -1, 0, 1 If self is frozen, raise ValueError.
source code
    Copying
 
__deepcopy__(self, memo) source code

Inherited from FeatStruct: copy

    Uniform Accessor Methods
 
_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
    String Representations
 
_repr(self, reentrances, reentrance_ids)
Returns: A string representation of this feature structure.
source code

Inherited from FeatStruct: __repr__

    Equality & Hashing

Inherited from FeatStruct: __eq__, __hash__, __ne__, equal_values

Inherited from FeatStruct (private): _equal, _hash

    Freezing

Inherited from FeatStruct: freeze, frozen

Inherited from FeatStruct (private): _freeze

    Structural Information

Inherited from FeatStruct: cyclic, reentrances, walk

Inherited from FeatStruct (private): _find_reentrances, _walk

    Variables & Bindings

Inherited from FeatStruct: remove_variables, rename_variables, retract_bindings, substitute_bindings, variables

    Unification

Inherited from FeatStruct: subsumes, unify

Static Methods [hide private]
    Constructor

Inherited from FeatStruct: __new__

Class Variables [hide private]
    List methods
  _INDEX_ERROR = 'Expected int or feature path. Got %r.'
    Freezing

Inherited from FeatStruct (private): _FROZEN_ERROR

Instance Variables [hide private]

Inherited from FeatStruct (private): _frozen

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, features=())
(Constructor)

source code 

Create a new feature list, with the specified features.

Parameters:
  • features - The initial list of features for this feature list. If features is a string, then it is paresd using FeatStructParser. Otherwise, it should be a sequence of basic values and nested feature structures.
Returns: new list
Overrides: list.__init__

__getitem__(self, name_or_path)
(Indexing operator)

source code 

x[y]

Overrides: list.__getitem__
(inherited documentation)

__delitem__(self, name_or_path)
(Index deletion operator)

source code 

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

Overrides: list.__delitem__

__setitem__(self, name_or_path, value)
(Index assignment operator)

source code 

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

Overrides: list.__setitem__

__delslice__(x, i, j)
(Slice deletion operator)

source code 

del x[i:j]

Use of negative indices is not supported. If self is frozen, raise ValueError.

Overrides: list.__delslice__

__setslice__(x, i, j, y)
(Slice assignment operator)

source code 

x[i:j]=y

Use of negative indices is not supported. If self is frozen, raise ValueError.

Overrides: list.__setslice__

__iadd__(x, y)

source code 

x+=y If self is frozen, raise ValueError.

Overrides: list.__iadd__

__imul__(x, y)

source code 

x*=y If self is frozen, raise ValueError.

Overrides: list.__imul__

append(L, object)

source code 

append object to end If self is frozen, raise ValueError.

Overrides: list.append

extend(L, iterable)

source code 

extend list by appending elements from the iterable If self is frozen, raise ValueError.

Overrides: list.extend

insert(L, index, object)

source code 

insert object before index If self is frozen, raise ValueError.

Overrides: list.insert

pop(L, index=...)

source code 

remove and return item at index (default last) If self is frozen, raise ValueError.

Returns: item
Overrides: list.pop

remove(L, value)

source code 

remove first occurrence of value If self is frozen, raise ValueError.

Overrides: list.remove

reverse(L)

source code 

reverse *IN PLACE* If self is frozen, raise ValueError.

Overrides: list.reverse

sort(L, cmp=None, key=None, reverse=False)

source code 

stable sort *IN PLACE*; cmp(x, y) -> -1, 0, 1 If self is frozen, raise ValueError.

Overrides: list.sort

__deepcopy__(self, memo)

source code 
Overrides: FeatStruct.__deepcopy__

_keys(self)

source code 

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

Overrides: FeatStruct._keys
(inherited documentation)

_values(self)

source code 

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

Overrides: FeatStruct._values
(inherited documentation)

_items(self)

source code 

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.

Overrides: FeatStruct._items
(inherited documentation)

_repr(self, reentrances, reentrance_ids)

source code 
Parameters:
  • reentrances - A dictionary that maps from the id of each feature value in self, indicating whether that value is reentrant or not.
  • reentrance_ids - A dictionary mapping from the ids of feature values to unique identifiers. 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 string representation of this feature structure.
Overrides: FeatStruct._repr
(inherited documentation)