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

Accesses links within the graph

Returns:a list of corenlp_xml.dependencies.DependencyLink instances
Type:list of corenlp_xml.dependencies.DependencyLink

Accesses links within the graph

Parameters:dep_type (str) – the depency type
Returns:a list of corenlp_xml.dependencies.DependencyLink instances
Type:list of corenlp_xml.dependencies.DependencyLink

Represents a relationship between two nodes in a dependency graph

dependent[source]

Accesses the dependent node

Getter:returns the Dependent node
Type:corenlp_xml.dependencies.DependencyNode
governor[source]

Accesses the governor node

Getter:Returns the Governor node
Type:corenlp_xml.dependencies.DependencyNode
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:
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:
text = None

These properties are dicts of link type to node