Package nltk :: Package corpus :: Package reader :: Module plaintext :: Class CategorizedPlaintextCorpusReader
[hide private]
[frames] | no frames]

Class CategorizedPlaintextCorpusReader

source code

                 object --+    
                          |    
api.CategorizedCorpusReader --+
                              |
             object --+       |
                      |       |
       api.CorpusReader --+   |
                          |   |
      PlaintextCorpusReader --+
                              |
                             CategorizedPlaintextCorpusReader

A reader for plaintext corpora whose documents are divided into categories based on their file identifiers.

Nested Classes [hide private]

Inherited from PlaintextCorpusReader: CorpusView

Instance Methods [hide private]
 
__init__(self, *args, **kwargs)
Initialize the corpus reader.
source code
 
_resolve(self, files, categories) source code
str
raw(self, files=None, categories=None)
Returns: the given file or files as a single string.
source code
list of str
words(self, files=None, categories=None)
Returns: the given file or files as a list of words and punctuation symbols.
source code
list of (list of str)
sents(self, files=None, categories=None)
Returns: the given file or files as a list of sentences or utterances, each encoded as a list of word strings.
source code
list of (list of (list of str))
paras(self, files=None, categories=None)
Returns: the given file or files as a list of paragraphs, each encoded as a list of sentences, which are in turn encoded as lists of word strings.
source code

Inherited from api.CategorizedCorpusReader: categories, files

Inherited from api.CategorizedCorpusReader (private): _add, _init

Inherited from api.CorpusReader: __repr__, abspath, abspaths, encoding, open

Inherited from api.CorpusReader (private): _get_root

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

    Deprecated since 0.8

Inherited from PlaintextCorpusReader: read, tokenized

    Deprecated since 0.9.1

Inherited from api.CorpusReader: filenames

Inherited from api.CorpusReader (private): _get_items

Instance Variables [hide private]

Inherited from api.CorpusReader (private): _encoding, _files, _root

Properties [hide private]

Inherited from api.CorpusReader: root

Inherited from object: __class__

    Deprecated since 0.9.1

Inherited from api.CorpusReader: items

Method Details [hide private]

__init__(self, *args, **kwargs)
(Constructor)

source code 

Initialize the corpus reader. Categorization arguments (cat_pattern, cat_map, and cat_file) are passed to the CategorizedCorpusReader constructor. The remaining arguments are passed to the PlaintextCorpusReader constructor.

Overrides: api.CategorizedCorpusReader.__init__

raw(self, files=None, categories=None)

source code 
Returns: str
the given file or files as a single string.
Overrides: PlaintextCorpusReader.raw
(inherited documentation)

words(self, files=None, categories=None)

source code 
Returns: list of str
the given file or files as a list of words and punctuation symbols.
Overrides: PlaintextCorpusReader.words
(inherited documentation)

sents(self, files=None, categories=None)

source code 
Returns: list of (list of str)
the given file or files as a list of sentences or utterances, each encoded as a list of word strings.
Overrides: PlaintextCorpusReader.sents
(inherited documentation)

paras(self, files=None, categories=None)

source code 
Returns: list of (list of (list of str))
the given file or files as a list of paragraphs, each encoded as a list of sentences, which are in turn encoded as lists of word strings.
Overrides: PlaintextCorpusReader.paras
(inherited documentation)