nltk.corpus.reader.pl196x module

class nltk.corpus.reader.pl196x.TEICorpusView[source]

Bases: nltk.corpus.reader.util.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 with block_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 a PathPointer.

  • 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_block(stream)[source]

Read a block from the input stream.

Returns

a block of tokens from the input stream

Return type

list(any)

Parameters

stream (stream) – an input stream

class nltk.corpus.reader.pl196x.Pl196xCorpusReader[source]

Bases: nltk.corpus.reader.api.CategorizedCorpusReader, nltk.corpus.reader.xmldocs.XMLCorpusReader

head_len = 2770
__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.

decode_tag(tag)[source]
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)

sents(fileids=None, categories=None, textids=None)[source]
paras(fileids=None, categories=None, textids=None)[source]
tagged_words(fileids=None, categories=None, textids=None)[source]
tagged_sents(fileids=None, categories=None, textids=None)[source]
tagged_paras(fileids=None, categories=None, textids=None)[source]
xml(fileids=None, categories=None)[source]