nltk.corpus.reader.PropbankCorpusReader

class nltk.corpus.reader.PropbankCorpusReader[source]

Bases: CorpusReader

Corpus reader for the propbank corpus, which augments the Penn Treebank with information about the predicate argument structure of every verb instance. The corpus consists of two parts: the predicate-argument annotations themselves, and a set of “frameset files” which define the argument labels used by the annotations, on a per-verb basis. Each “frameset file” contains one or more predicates, such as 'turn' or 'turn_on', each of which is divided into coarse-grained word senses called “rolesets”. For each “roleset”, the frameset file provides descriptions of the argument roles, along with examples.

__init__(root, propfile, framefiles='', verbsfile=None, parse_fileid_xform=None, parse_corpus=None, encoding='utf8')[source]
Parameters
  • root – The root directory for this corpus.

  • propfile – The name of the file containing the predicate- argument annotations (relative to root).

  • framefiles – A list or regexp specifying the frameset fileids for this corpus.

  • parse_fileid_xform – A transform that should be applied to the fileids in this corpus. This should be a function of one argument (a fileid) that returns a string (the new fileid).

  • parse_corpus – The corpus containing the parse trees corresponding to this corpus. These parse trees are necessary to resolve the tree pointers used by propbank.

instances(baseform=None)[source]
Returns

a corpus view that acts as a list of PropBankInstance objects, one for each noun in the corpus.

lines()[source]
Returns

a corpus view that acts as a list of strings, one for each line in the predicate-argument annotation file.

roleset(roleset_id)[source]
Returns

the xml description for the given roleset.

rolesets(baseform=None)[source]
Returns

list of xml descriptions for rolesets.

verbs()[source]
Returns

a corpus view that acts as a list of all verb lemmas in this corpus (from the verbs.txt file).

abspath(fileid)[source]

Return the absolute path for the given file.

Parameters

fileid (str) – The file identifier for the file whose path should be returned.

Return type

PathPointer

abspaths(fileids=None, include_encoding=False, include_fileid=False)[source]

Return a list of the absolute paths for all fileids in this corpus; or for the given list of fileids, if specified.

Parameters
  • fileids (None or str or list) – Specifies the set of fileids for which paths should be returned. Can be None, for all fileids; a list of file identifiers, for a specified set of fileids; or a single file identifier, for a single file. Note that the return value is always a list of paths, even if fileids is a single file identifier.

  • include_encoding – If true, then return a list of (path_pointer, encoding) tuples.

Return type

list(PathPointer)

citation()[source]

Return the contents of the corpus citation.bib file, if it exists.

encoding(file)[source]

Return the unicode encoding for the given corpus file, if known. If the encoding is unknown, or if the given file should be processed using byte strings (str), then return None.

ensure_loaded()[source]

Load this corpus (if it has not already been loaded). This is used by LazyCorpusLoader as a simple method that can be used to make sure a corpus is loaded – e.g., in case a user wants to do help(some_corpus).

fileids()[source]

Return a list of file identifiers for the fileids that make up this corpus.

license()[source]

Return the contents of the corpus LICENSE file, if it exists.

open(file)[source]

Return an open stream that can be used to read the given file. If the file’s encoding is not None, then the stream will automatically decode the file’s contents into unicode.

Parameters

file – The file identifier of the file to read.

raw(fileids=None)[source]
Parameters

fileids – A list specifying the fileids that should be used.

Returns

the given file(s) as a single string.

Return type

str

readme()[source]

Return the contents of the corpus README file, if it exists.

property root

The directory where this corpus is stored.

Type

PathPointer