verbnetreader¶
Read VerbNet and build a list of allowed VerbNet frame for each verb
- class verbnetreader.VerbnetReader(path, normalize=False)[source]¶
Bases: builtins.object
Class used to parse VerbNet and build its representation in memory.
Variables: verbs – Dictionary of VerbnetOfficialFrame lists representing VerbNet. - _build_frame(xml_frame, vnclass, role_list, restrictions)[source]¶
Parse one frame
Parameters: - xml_frame (xml.etree.ElementTree.Element.) – XML representation of the frame.
- vnclass (str.) – The VerbNet class to which the frame belongs.
- _build_structure(base_structure, syntax_data, vnclass, role_list)[source]¶
Build the final structure from base_structure
Parameters: - base_structure (str List) – The base structure
- syntax_data (xml.etree.ElementTree.Element) – The XML “SYNTAX” node
- vnclass (str) – The VerbNet class of the frame
Returns: (str | str List) List – the final structure
- _handle_class(xml_class, parent_frames, role_list, restrictions)[source]¶
Parse one class of verbs and all its subclasses.
Parameters: - xml_class (xml.etree.ElementTree.Element.) – XML representation of the class of verbs.
- parent_frames (VerbnetOfficialFrame list.) – the frame inherited from the parent class.
- _handle_lex(xml, base_structure)[source]¶
Choose wether or not to keep a <LEX> entry
Parameters: xml – The <LEX> entry. :type xml:xml.etree.ElementTree.Element. :param base_structure: The VerbNet primary structure. :type base_structure: str List. :returns: String the lexeme value if accepted, “” otherwise
- _handle_prep(xml)[source]¶
Generate the list of acceptable preposition from a <PREP> entry
Parameters: xml – The <PREP> entry. :type xml:xml.etree.ElementTree.Element. :returns: String List - the list of acceptable prepositions
- _read_syntax_data(index_xml, syntax_data, elem, base_structure)[source]¶
Look for a node of SYNTAX that match the current element and tells whether a keyword was found between the old and new position
Parameters: - index_xml – The current position
- syntax_data (xml.etree.ElementTree.Element) – The XML “SYNTAX” node
- elem (str) – The element to look for (VerbNet syntax)
- base_structure (str List) – The frame base structure (for _handle_lex)
Returns: (int, str) – the new position and a keyword if one is found