Interacting with Dependencies¶
This component is responsible for managing dependency parses
- class corenlp_xml.dependencies.DependencyGraph(element)[source]¶
Dependency graph, models a dependency parse
- get_node_by_idx(idx)[source]¶
Stores each distinct node in a dict
Parameters: idx (int) – the “idx” value of the node Returns: the node instance for that index Type: corenlp_xml.dependencies.DependencyNode
- class corenlp_xml.dependencies.DependencyLink(graph, element)[source]¶
Represents a relationship between two nodes in a dependency graph
- class corenlp_xml.dependencies.DependencyNode(graph, element)[source]¶
Represents a node in a dependency graph
- dependent(dep_type, node)[source]¶
Registers a node as dependent on this node
Parameters: - dep_type (str) – The dependency type
- node (corenlp_xml.dependencies.DependencyNode) – The node to be registered as a dependent
Returns: self, provides fluent interface
Return type: corenlp_xml.dependencies.DependencyNode
- dependents[source]¶
Gets dependent nodes
Getter: returns a flat list of all governing nodes Type: list of corenlp_xml.dependencies.DependencyNode
- dependents_by_type(dep_type)[source]¶
Gets the dependents of this node by a given dependency type
Parameters: dep_type (str) – The dependency type Returns: dependents matching the provided type
- governor(dep_type, node)[source]¶
Registers a node as governing this node
Parameters: - dep_type (str) – The dependency type
- node –
Returns: self, provides fluent interface
Return type: corenlp_xml.dependencies.DependencyNode
- governors[source]¶
Gets governing nodes
Getter: returns a flat list of all governing nodes Type: list of corenlp_xml.dependencies.DependencyNode
- governors_by_type(dep_type)[source]¶
Gets the governors of this node filtered by a dependency type
Parameters: dep_type (str) – The dependency type Returns: governors matching the provided type
- classmethod load(graph, element)[source]¶
Instantiates the node in the graph if it’s not already stored in the graph
Parameters: - graph (corenlp_xml.dependencies.DependencyGraph) – The dependency graph this node is a member of
- element (lxml.ElementBase) – The lxml element wrapping the node
- text = None¶
These properties are dicts of link type to node