class DotTreeTransformator(DotTransformator, InplaceTreeTransformator): def __init__(self): DotTransformator.__init__(self) TreeTransformator.__init__(self) from yargy.relations.graph import RelationsGraph self.relations = RelationsGraph() def __call__(self, root): graph = super(DotTreeTransformator, self).__call__(root) for edge in self.relations.edges: graph.add_edge(edge.first, edge.second, style=style(label=edge.relation.label, dir='none', style='dashed')) return graph def visit_Node(self, item): color = (GREEN if item.interpretator else BLUE) self.style(item, style(label=item.label, fillcolor=color)) if item.relation: self.relations.add(item.relation, item) def visit_Leaf(self, item): self.style(item, style(label=item.label))
class DotTreeTransformator(DotTransformator, InplaceTreeTransformator): def __init__(self): DotTransformator.__init__(self) TreeTransformator.__init__(self) from yargy.relations.graph import RelationsGraph self.relations = RelationsGraph() def __call__(self, root): graph = super(DotTreeTransformator, self).__call__(root) for edge in self.relations.edges: graph.add_edge( edge.first, edge.second, style=style( label=edge.relation.label, dir='none', style='dashed' ) ) return graph def visit_Node(self, item): color = ( GREEN if item.interpretator else BLUE ) self.style( item, style(label=item.label, fillcolor=color) ) if item.relation: self.relations.add(item.relation, item) def visit_Leaf(self, item): self.style( item, style(label=item.label) )
def __init__(self): DotTransformator.__init__(self) TreeTransformator.__init__(self) from yargy.relations.graph import RelationsGraph self.relations = RelationsGraph()