Package nltk :: Module sourcedstring :: Class SourcedStringStream
[hide private]
[frames] | no frames]

type SourcedStringStream

source code

object --+
         |
        SourcedStringStream

Wrapper for a read-only stream that causes read() (and related methods) to return sourced strings. seek() and tell() are supported, but (currently) there are some restrictions on the values that may be passed to seek().

Nested Classes [hide private]
SourcedStringStreamPos
Instance Methods [hide private]
 
__init__(self, stream, docid=None, byte_offsets=False) source code
 
read(self, size=None) source code
 
readline(self, size=None) source code
list of unicode
readlines(self, sizehint=None, keepends=True)
Read this file's contents, decode them using this reader's encoding, and return it as a list of unicode lines.
source code
 
next(self)
Return the next decoded line from the underlying stream.
source code
 
__iter__(self)
Return self
source code
 
xreadlines(self)
Return self
source code
 
_sourced_string(self, contents)
Turn the given string into an sourced string, and update charpos.
source code
 
close(self)
Close the underlying stream.
source code
 
seek(self, offset, whence=0) source code
 
tell(self) source code
Instance Variables [hide private]
  stream
The underlying stream.
  docid
The docid attribute for sourced strings
  charpos
The current character (not byte) position
Properties [hide private]
  closed
True if the underlying stream is closed.
  name
The name of the underlying stream.
  mode
The mode of the underlying stream.
Method Details [hide private]

__init__(self, stream, docid=None, byte_offsets=False)
(Constructor)

source code 
Overrides: object.__init__
(inherited documentation)

readlines(self, sizehint=None, keepends=True)

source code 

Read this file's contents, decode them using this reader's encoding, and return it as a list of unicode lines.

Parameters:
  • sizehint - Ignored.
  • keepends - If false, then strip newlines.
Returns: list of unicode

Property Details [hide private]

closed

True if the underlying stream is closed.

name

The name of the underlying stream.

mode

The mode of the underlying stream.