- class nltk.corpus.reader.pl196x.TEICorpusView¶
- __init__(corpus_file, tagged, group_by_sent, group_by_para, tagset=None, head_len=0, textids=None)¶
Create a new corpus view, based on the file
fileid, and read with
block_reader. See the class documentation for more information.
fileid – The path to the file that is read by this corpus view.
fileidcan either be a string or a
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).
Read a block from the input stream.
a block of tokens from the input stream
- Return type
stream (stream) – an input stream
- class nltk.corpus.reader.pl196x.Pl196xCorpusReader¶
- head_len = 2770¶
- __init__(*args, **kwargs)¶
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_delimitercan 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.
- textids(fileids=None, categories=None)¶
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)¶
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.
the given file’s text nodes as a list of words and punctuation symbols
- Return type
- sents(fileids=None, categories=None, textids=None)¶
- paras(fileids=None, categories=None, textids=None)¶
- tagged_words(fileids=None, categories=None, textids=None)¶
- tagged_sents(fileids=None, categories=None, textids=None)¶
- tagged_paras(fileids=None, categories=None, textids=None)¶
- xml(fileids=None, categories=None)¶