Package nltk :: Module util :: Class LazySubsequence
[hide private]
[frames] | no frames]

Class LazySubsequence

source code

          object --+    
                   |    
AbstractLazySequence --+
                       |
                      LazySubsequence

A subsequence produced by slicing a lazy sequence. This slice keeps a reference to its source sequence, and generates its values by looking them up in the source sequence.

Instance Methods [hide private]
 
__init__(self, source, start, stop)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
__len__(self)
Return the number of tokens in the corpus file underlying this corpus view.
source code
 
iterate_from(self, start)
Return an iterator that generates the tokens in the corpus file underlying this corpus view, starting at the token number start.
source code

Inherited from AbstractLazySequence: __add__, __cmp__, __contains__, __getitem__, __hash__, __iter__, __mul__, __radd__, __repr__, __rmul__, count, index

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

Static Methods [hide private]
a new object with type S, a subtype of T
__new__(cls, source, start, stop)
Construct a new slice from a given underlying sequence.
source code
Class Variables [hide private]
  MIN_SIZE = 100
The minimum size for which lazy slices should be created.

Inherited from AbstractLazySequence (private): _MAX_REPR_SIZE

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__new__(cls, source, start, stop)
Static Method

source code 

Construct a new slice from a given underlying sequence. The start and stop indices should be absolute indices -- i.e., they should not be negative (for indexing from the back of a list) or greater than the length of source.

Returns: a new object with type S, a subtype of T
Overrides: object.__new__

__init__(self, source, start, stop)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

__len__(self)
(Length operator)

source code 

Return the number of tokens in the corpus file underlying this corpus view.

Overrides: AbstractLazySequence.__len__
(inherited documentation)

iterate_from(self, start)

source code 

Return an iterator that generates the tokens in the corpus file underlying this corpus view, starting at the token number start. If start>=len(self), then this iterator will generate no tokens.

Overrides: AbstractLazySequence.iterate_from
(inherited documentation)

Class Variable Details [hide private]

MIN_SIZE

The minimum size for which lazy slices should be created. If LazySubsequence() is called with a subsequence that is shorter than MIN_SIZE, then a tuple will be returned instead.

Value:
100