class documentation

An NLTK interface to the VerbNet verb lexicon.

From the VerbNet site: "VerbNet (VN) (Kipper-Schuler 2006) is the largest on-line verb lexicon currently available for English. It is a hierarchical domain-independent, broad-coverage verb lexicon with mappings to other lexical resources such as WordNet (Miller, 1990; Fellbaum, 1998), XTAG (XTAG Research Group, 2001), and FrameNet (Baker et al., 1998)."

For details about VerbNet see: https://verbs.colorado.edu/~mpalmer/projects/verbnet.html

Method __init__ No summary
Method classids Return a list of the VerbNet class identifiers. If a file identifier is specified, then return only the VerbNet class identifiers for classes (and subclasses) defined by that file. If a lemma is specified, then return only VerbNet class identifiers for classes that contain that lemma as a member...
Method fileids Return a list of fileids that make up this corpus. If vnclass_ids is specified, then return the fileids that make up the specified VerbNet class(es).
Method frames Given a VerbNet class, this method returns VerbNet frames
Method lemmas Return a list of all verb lemmas that appear in any class, or in the classid if specified.
Method longid Returns longid of a VerbNet class
Method pprint Returns pretty printed version of a VerbNet class
Method pprint_frames Returns pretty version of all frames in a VerbNet class
Method pprint_members Returns pretty printed version of members in a VerbNet class
Method pprint_subclasses Returns pretty printed version of subclasses of VerbNet class
Method pprint_themroles Returns pretty printed version of thematic roles in a VerbNet class
Method shortid Returns shortid of a VerbNet class
Method subclasses Returns subclass ids, if any exist
Method themroles Returns thematic roles participating in a VerbNet class
Method vnclass Returns VerbNet class ElementTree
Method wordnetids Return a list of all wordnet identifiers that appear in any class, or in classid if specified.
Method _get_description_within_frame Returns member description within frame
Method _get_example_within_frame Returns example within a frame
Method _get_semantics_within_frame Returns semantics within a single frame
Method _get_syntactic_list_within_frame Returns semantics within a frame
Method _index Initialize the indexes _lemma_to_class, _wordnet_to_class, and _class_to_fileid by scanning through the corpus fileids. This is fast if ElementTree uses the C implementation (<0.1 secs), but quite slow (>10 secs) if only the python implementation is available.
Method _index_helper Helper for _index()
Method _pprint_description_within_frame Returns pretty printed version of a VerbNet frame description
Method _pprint_example_within_frame Returns pretty printed version of example within frame in a VerbNet class
Method _pprint_semantics_within_frame Returns a pretty printed version of semantics within frame in a VerbNet class
Method _pprint_single_frame Returns pretty printed version of a single frame in a VerbNet class
Method _pprint_syntax_within_frame Returns pretty printed version of syntax within a frame in a VerbNet class
Method _quick_index Initialize the indexes _lemma_to_class, _wordnet_to_class, and _class_to_fileid by scanning through the corpus fileids. This doesn't do proper xml parsing, but is good enough to find everything in the standard VerbNet corpus -- and it runs about 30 times faster than xml parsing (with the python ElementTree; only 2-3 times faster if ElementTree uses the C implementation).
Constant _INDEX_RE Regular expression used by _index() to quickly scan the corpus for basic information.
Constant _LONGID_RE Regular expression that matches (and decomposes) longids
Constant _SHORTID_RE Regular expression that matches shortids
Instance Variable _class_to_fileid A dictionary mapping from class identifiers to corresponding file identifiers. The keys of this dictionary provide a complete list of all classes and subclasses.
Instance Variable _lemma_to_class A dictionary mapping from verb lemma strings to lists of VerbNet class identifiers.
Instance Variable _shortid_to_longid Undocumented
Instance Variable _wordnet_to_class A dictionary mapping from wordnet identifier strings to lists of VerbNet class identifiers.

Inherited from XMLCorpusReader:

Method raw Undocumented
Method words 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.
Method xml Undocumented
Instance Variable _wrap_etree Undocumented

Inherited from CorpusReader (via XMLCorpusReader):

Method __repr__ Undocumented
Method abspath Return the absolute path for the given file.
Method abspaths Return a list of the absolute paths for all fileids in this corpus; or for the given list of fileids, if specified.
Method citation Return the contents of the corpus citation.bib file, if it exists.
Method encoding 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.
Method ensure_loaded 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).
Method license Return the contents of the corpus LICENSE file, if it exists.
Method open 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.
Method readme Return the contents of the corpus README file, if it exists.
Class Variable root Undocumented
Method _get_root Undocumented
Instance Variable _encoding The default unicode encoding for the fileids that make up this corpus. If encoding is None, then the file contents are processed using byte strings.
Instance Variable _fileids A list of the relative paths for the fileids that make up this corpus.
Instance Variable _root The root directory for this corpus.
Instance Variable _tagset Undocumented
def __init__(self, root, fileids, wrap_etree=False): (source)
Parameters
root:PathPointer or strA path pointer identifying the root directory for this corpus. If a string is specified, then it will be converted to a PathPointer automatically.
fileidsA 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.
wrap_etreeUndocumented
encoding

The default unicode encoding for the files that make up the corpus. The value of encoding 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.
tagsetThe name of the tagset used by this corpus, to be used for normalizing or converting the POS tags returned by the tagged_...() methods.
def classids(self, lemma=None, wordnetid=None, fileid=None, classid=None): (source)

Return a list of the VerbNet class identifiers. If a file identifier is specified, then return only the VerbNet class identifiers for classes (and subclasses) defined by that file. If a lemma is specified, then return only VerbNet class identifiers for classes that contain that lemma as a member. If a wordnetid is specified, then return only identifiers for classes that contain that wordnetid as a member. If a classid is specified, then return only identifiers for subclasses of the specified VerbNet class. If nothing is specified, return all classids within VerbNet

def fileids(self, vnclass_ids=None): (source)

Return a list of fileids that make up this corpus. If vnclass_ids is specified, then return the fileids that make up the specified VerbNet class(es).

def frames(self, vnclass): (source)

Given a VerbNet class, this method returns VerbNet frames

The members returned are: 1) Example 2) Description 3) Syntax 4) Semantics

Parameters
vnclassA VerbNet class identifier; or an ElementTree containing the xml contents of a VerbNet class.
Returns
frames - a list of frame dictionaries
def lemmas(self, vnclass=None): (source)

Return a list of all verb lemmas that appear in any class, or in the classid if specified.

def longid(self, shortid): (source)

Returns longid of a VerbNet class

Given a short VerbNet class identifier (eg '37.10'), map it to a long id (eg 'confess-37.10'). If shortid is already a long id, then return it as-is

def pprint(self, vnclass): (source)

Returns pretty printed version of a VerbNet class

Return a string containing a pretty-printed representation of the given VerbNet class.

containing the xml contents of a VerbNet class.

Parameters
vnclassA VerbNet class identifier; or an ElementTree
def pprint_frames(self, vnclass, indent=''): (source)

Returns pretty version of all frames in a VerbNet class

Return a string containing a pretty-printed representation of the list of frames within the VerbNet class.

Parameters
vnclassA VerbNet class identifier; or an ElementTree containing the xml contents of a VerbNet class.
indentUndocumented
def pprint_members(self, vnclass, indent=''): (source)

Returns pretty printed version of members in a VerbNet class

Return a string containing a pretty-printed representation of the given VerbNet class's member verbs.

Parameters
vnclassA VerbNet class identifier; or an ElementTree containing the xml contents of a VerbNet class.
indentUndocumented
def pprint_subclasses(self, vnclass, indent=''): (source)

Returns pretty printed version of subclasses of VerbNet class

Return a string containing a pretty-printed representation of the given VerbNet class's subclasses.

Parameters
vnclassA VerbNet class identifier; or an ElementTree containing the xml contents of a VerbNet class.
indentUndocumented
def pprint_themroles(self, vnclass, indent=''): (source)

Returns pretty printed version of thematic roles in a VerbNet class

Return a string containing a pretty-printed representation of the given VerbNet class's thematic roles.

Parameters
vnclassA VerbNet class identifier; or an ElementTree containing the xml contents of a VerbNet class.
indentUndocumented
def shortid(self, longid): (source)

Returns shortid of a VerbNet class

Given a long VerbNet class identifier (eg 'confess-37.10'), map it to a short id (eg '37.10'). If longid is already a short id, then return it as-is.

def subclasses(self, vnclass): (source)

Returns subclass ids, if any exist

Given a VerbNet class, this method returns subclass ids (if they exist) in a list of strings.

Parameters
vnclassA VerbNet class identifier; or an ElementTree containing the xml contents of a VerbNet class.
Returns
list of subclasses
def themroles(self, vnclass): (source)

Returns thematic roles participating in a VerbNet class

Members returned as part of roles are- 1) Type 2) Modifiers

Parameters
vnclassA VerbNet class identifier; or an ElementTree containing the xml contents of a VerbNet class.
Returns
themroles: A list of thematic roles in the VerbNet class
def vnclass(self, fileid_or_classid): (source)

Returns VerbNet class ElementTree

Return an ElementTree containing the xml for the specified VerbNet class.

Parameters
fileid_or_classidAn identifier specifying which class should be returned. Can be a file identifier (such as 'put-9.1.xml'), or a VerbNet class identifier (such as 'put-9.1') or a short VerbNet class identifier (such as '9.1').
def wordnetids(self, vnclass=None): (source)

Return a list of all wordnet identifiers that appear in any class, or in classid if specified.

def _get_description_within_frame(self, vnframe): (source)

Returns member description within frame

A utility function to retrieve a description of participating members within a frame in VerbNet.

Parameters
vnframeAn ElementTree containing the xml contents of a VerbNet frame.
Returns
description: a description dictionary with members - primary and secondary
def _get_example_within_frame(self, vnframe): (source)

Returns example within a frame

A utility function to retrieve an example within a frame in VerbNet.

Parameters
vnframeAn ElementTree containing the xml contents of a VerbNet frame.
Returns
example_text: The example sentence for this particular frame
def _get_semantics_within_frame(self, vnframe): (source)

Returns semantics within a single frame

A utility function to retrieve semantics within a frame in VerbNet Members of the semantics dictionary: 1) Predicate value 2) Arguments

Parameters
vnframeAn ElementTree containing the xml contents of a VerbNet frame.
Returns
semantics: semantics dictionary
def _get_syntactic_list_within_frame(self, vnframe): (source)

Returns semantics within a frame

A utility function to retrieve semantics within a frame in VerbNet. Members of the syntactic dictionary: 1) POS Tag 2) Modifiers

Parameters
vnframeAn ElementTree containing the xml contents of a VerbNet frame.
Returns
syntax_within_single_frame
def _index(self): (source)

Initialize the indexes _lemma_to_class, _wordnet_to_class, and _class_to_fileid by scanning through the corpus fileids. This is fast if ElementTree uses the C implementation (<0.1 secs), but quite slow (>10 secs) if only the python implementation is available.

def _index_helper(self, xmltree, fileid): (source)

Helper for _index()

def _pprint_description_within_frame(self, vnframe, indent=''): (source)

Returns pretty printed version of a VerbNet frame description

Return a string containing a pretty-printed representation of the given VerbNet frame description.

Parameters
vnframeAn ElementTree containing the xml contents of a VerbNet frame.
indentUndocumented
def _pprint_example_within_frame(self, vnframe, indent=''): (source)

Returns pretty printed version of example within frame in a VerbNet class

Return a string containing a pretty-printed representation of the given VerbNet frame example.

Parameters
vnframeAn ElementTree containing the xml contents of a Verbnet frame.
indentUndocumented
def _pprint_semantics_within_frame(self, vnframe, indent=''): (source)

Returns a pretty printed version of semantics within frame in a VerbNet class

Return a string containing a pretty-printed representation of the given VerbNet frame semantics.

Parameters
vnframeAn ElementTree containing the xml contents of a VerbNet frame.
indentUndocumented
def _pprint_single_frame(self, vnframe, indent=''): (source)

Returns pretty printed version of a single frame in a VerbNet class

Returns a string containing a pretty-printed representation of the given frame.

Parameters
vnframeAn ElementTree containing the xml contents of a VerbNet frame.
indentUndocumented
def _pprint_syntax_within_frame(self, vnframe, indent=''): (source)

Returns pretty printed version of syntax within a frame in a VerbNet class

Return a string containing a pretty-printed representation of the given VerbNet frame syntax.

Parameters
vnframeAn ElementTree containing the xml contents of a VerbNet frame.
indentUndocumented
def _quick_index(self): (source)

Initialize the indexes _lemma_to_class, _wordnet_to_class, and _class_to_fileid by scanning through the corpus fileids. This doesn't do proper xml parsing, but is good enough to find everything in the standard VerbNet corpus -- and it runs about 30 times faster than xml parsing (with the python ElementTree; only 2-3 times faster if ElementTree uses the C implementation).

_INDEX_RE = (source)

Regular expression used by _index() to quickly scan the corpus for basic information.

Value
re.compile(r'<MEMBER name="\??([^"]+)" wn="([^"]*)"[^>]+>|VNSUBCLASS ID="([^"]+)
"/?>')
_LONGID_RE = (source)

Regular expression that matches (and decomposes) longids

Value
re.compile(r'([^-\.]*)-([\d\+\.-]+)$')
_SHORTID_RE = (source)

Regular expression that matches shortids

Value
re.compile(r'[\d\+\.-]+$')
_class_to_fileid: dict = (source)

A dictionary mapping from class identifiers to corresponding file identifiers. The keys of this dictionary provide a complete list of all classes and subclasses.

_lemma_to_class = (source)

A dictionary mapping from verb lemma strings to lists of VerbNet class identifiers.

_shortid_to_longid: dict = (source)

Undocumented

_wordnet_to_class = (source)

A dictionary mapping from wordnet identifier strings to lists of VerbNet class identifiers.