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

type CategorizedPlaintextCorpusReader

source code

                 object --+    
                          |    
api.CategorizedCorpusReader --+
                              |
             object --+       |
                      |       |
       api.CorpusReader --+   |
                          |   |
      PlaintextCorpusReader --+
                              |
                             CategorizedPlaintextCorpusReader
Known Subclasses:

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, fileids, categories) source code
str
raw(self, fileids=None, categories=None)
Returns: the given file(s) as a single string.
source code
list of str
words(self, fileids=None, categories=None)
Returns: the given file(s) as a list of words and punctuation symbols.
source code
list of (list of str)
sents(self, fileids=None, categories=None)
Returns: the given file(s) 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, fileids=None, categories=None)
Returns: the given file(s) 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, fileids

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

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

Inherited from api.CorpusReader (private): _get_root

    Deprecated since 0.9.7

Inherited from api.CorpusReader: files

    Deprecated since 0.9.1

Inherited from api.CorpusReader: items

Inherited from api.CorpusReader (private): _get_items

Instance Variables [hide private]

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

Properties [hide private]

Inherited from api.CorpusReader: root

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.

Parameters:
  • root - The root directory for this corpus.
  • fileids - A list or regexp specifying the fileids in this corpus.
  • word_tokenizer - Tokenizer for breaking sentences or paragraphs into words.
  • sent_tokenizer - Tokenizer for breaking paragraphs into words.
  • para_block_reader - The block reader used to divide the corpus into paragraph blocks.
Overrides: api.CorpusReader.__init__

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

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

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

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

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

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

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

source code 
Returns: list of (list of (list of str))
the given file(s) 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)