nltk.corpus.reader.pl196x module¶
- class nltk.corpus.reader.pl196x.Pl196xCorpusReader[source]¶
Bases:
CategorizedCorpusReader
,XMLCorpusReader
- __init__(*args, **kwargs)[source]¶
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.
- head_len = 2770¶
- textids(fileids=None, categories=None)[source]¶
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(fileids=None, categories=None, textids=None)[source]¶
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
the given file’s text nodes as a list of words and punctuation symbols
- Return type
list(str)
- class nltk.corpus.reader.pl196x.TEICorpusView[source]¶
Bases:
StreamBackedCorpusView
- __init__(corpus_file, tagged, group_by_sent, group_by_para, tagset=None, head_len=0, textids=None)[source]¶
Create a new corpus view, based on the file
fileid
, and read withblock_reader
. See the class documentation for more information.- Parameters
fileid – The path to the file that is read by this corpus view.
fileid
can either be a string or aPathPointer
.startpos – The file position at which the view will start reading. This can be used to skip over preface sections.
encoding – The unicode encoding that should be used to read the file’s contents. If no encoding is specified, then the file’s contents will be read as a non-unicode string (i.e., a str).