grafeno.linearizers.node_edges module¶
-
class
grafeno.linearizers.node_edges.
Linearizer
(node_header='', node_sep='n', edge_header='n', edge_sep='n', footer='', graph=None)¶ Bases:
object
This linearizer outputs the nodes first, and then the edges.
Parameters: node_header : string
A string to print before all other content.
node_sep : string
A string to print between nodes.
edge_header : string
A string to print after the nodes, and before the edges.
edge_sep : string
A string to print between edges.
footer : string
A string to print after all other content.
graph :
Graph
The graph to linearize.
Attributes
graph ( Graph
) The graph to linearize.Methods
-
filter_edge
(n, m, edge)¶ Override this method to exclude some edges from the output.
Parameters: n : int
The id of the head of the edge
m : int
The id of the child of the edge
edge : dict
The grammatemes of the edge to filter.
Returns: bool
Whether to include this edge in further processing.
-
filter_node
(node)¶ Override this method to exclude some nodes from the output.
Parameters: node : dict
The grammatemes of the node to filter.
Returns: bool
Whether to include this node in further processing.
-
linearize
()¶
-
process_edge
(n, m, edge)¶ This method generates a string representation of an edge. Override to customize.
Parameters: n : int
Id of the head node.
m : int
Id of the dependent node.
edge : dict
Returns: string
A string representation of the edge.
-
process_node
(node)¶ This method generates a string representation of a node. Override to customize.
Parameters: node : dict
The grammatemes of the node to transform.
Returns: string
A string representation of the node.
-