Package nltk :: Package corpus :: Package reader :: Module pl196x :: Class Pl196xCorpusReader
[hide private]
[frames] | no frames]

type Pl196xCorpusReader

source code

                 object --+    
                          |    
api.CategorizedCorpusReader --+
                              |
             object --+       |
                      |       |
       api.CorpusReader --+   |
                          |   |
    xmldocs.XMLCorpusReader --+
                              |
                             Pl196xCorpusReader

Instance Methods [hide private]
 
__init__(self, *args, **kwargs)
Initialize this mapping based on keyword arguments, as follows:
source code
 
_init_textids(self) source code
 
_add_textids(self, file_id, text_id) source code
 
_resolve(self, fileids, categories, textids=None) source code
 
decode_tag(self, tag) source code
 
textids(self, fileids=None, categories=None)
In the pl196x corpus each category is stored in single file and thus both methods provide identical functionality.
source code
list of str
words(self, fileids=None, categories=None, textids=None)
Returns all of the words and punctuation symbols in the specified file that were in text nodes -- ie, tags are ignored.
source code
 
sents(self, fileids=None, categories=None, textids=None) source code
 
paras(self, fileids=None, categories=None, textids=None) source code
 
tagged_words(self, fileids=None, categories=None, textids=None) source code
 
tagged_sents(self, fileids=None, categories=None, textids=None) source code
 
tagged_paras(self, fileids=None, categories=None, textids=None) source code
 
xml(self, fileids=None, categories=None) source code
 
raw(self, fileids=None, categories=None) 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.8

Inherited from xmldocs.XMLCorpusReader: read

    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

Class Variables [hide private]
  headLen = 2770
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 this mapping based on keyword arguments, as follows:

  • cat_pattern: A regular expression pattern used to find the category for each file identifier. The pattern will be applied to each file identifier, and the first matching group will be used as the category label for that file.
  • cat_map: A dictionary, mapping from file identifiers to category labels.
  • cat_file: The name of a file that contains the mapping from file identifiers to categories. The argument cat_delimiter can be used to specify a delimiter.

The corresponding argument will be deleted from kwargs. If more than one argument is specified, an exception will be raised.

Parameters:
  • root - A path pointer identifying the root directory for this corpus. If a string is specified, then it will be converted to a PathPointer automatically.
  • fileids - A list of the files that make up this corpus. This list can either be specified explicitly, as a list of strings; or implicitly, as a regular expression over file paths. The absolute path for each file will be constructed by joining the reader's root to each file name.
  • encoding - The default unicode encoding for the files that make up the corpus. encoding's value can be any of the following:
    • A string: encoding is the encoding name for all files.
    • A dictionary: encoding[file_id] is the encoding name for the file whose identifier is file_id. If file_id is not in encoding, then the file contents will be processed using non-unicode byte strings.
    • A list: encoding should be a list of (regexp, encoding) tuples. The encoding for a file whose identifier is file_id will be the encoding value for the first tuple whose regexp matches the file_id. If no tuple's regexp matches the file_id, the file contents will be processed using non-unicode byte strings.
    • None: the file contents of all files will be processed using non-unicode byte strings.
  • tag_mapping_function - A function for normalizing or simplifying the POS tags returned by the tagged_words() or tagged_sents() methods.
Overrides: api.CorpusReader.__init__
(inherited documentation)

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

source code 

In the pl196x corpus each category is stored in single file and thus both methods provide identical functionality. In order to accommodate finer granularity, a non-standard textids() method was implemented. All the main functions can be supplied with a list of required chunks---giving much more control to the user.

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

source code 

Returns all of the words and punctuation symbols in the specified file that were in text nodes -- ie, tags are ignored. Like the xml() method, fileid can only specify one file.

Returns: list of str
the given file's text nodes as a list of words and punctuation symbols
Overrides: xmldocs.XMLCorpusReader.words
(inherited documentation)

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

source code 
Overrides: xmldocs.XMLCorpusReader.xml

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

source code 
Overrides: xmldocs.XMLCorpusReader.raw