zensols.calamr.render namespace

Submodules

zensols.calamr.render.base module

Renderer AMR graphs.

class zensols.calamr.render.base.GraphRenderer(browser_manager, extension, rooted=True, visual_style=<factory>, sleep=0)[source]

Bases: ABC

Renders an igraph in to a file and then displays it. To render the graph, use render(). Then you can display it with show().

The implementation of rendering is done in subclasses.

__init__(browser_manager, extension, rooted=True, visual_style=<factory>, sleep=0)
browser_manager: BrowserManager

Detects and controls the screen.

display(out_file)[source]

Display the graph generated in file out_file.

Parameters:

out_file (Path) – the graph to display

display_all(out_files)[source]

Like display() but display several files at once. In some cases, this means a separate browser window with multiple tabs with just the selected graphs will be shown.

extension: str

The output file’s extension.

render_to_file(context, out_file)[source]

Render graph the graph.

Parameters:

context (RenderContext) – contains everything that is needed to render a graph

rooted: bool = True

Whether the graph should be drawn as a tree.

show(context)[source]

Render and display the document graph.

sleep: Union[int, float] = 0

The number of seconds to sleep before deleting the generated file to give the browser time to display.

visual_style: Settings

Contains the visualization sytle for the graph.

class zensols.calamr.render.base.RenderContext(doc_graph, heading=None, visual_style=None)[source]

Bases: Dictable

Contains everything that is needed to render a graph.

__init__(doc_graph, heading=None, visual_style=None)
doc_graph: DocumentGraph

The graph to render.

heading: str = None

The title to use as the heading.

visual_style: Dict[str, Any] = None

Any overriding context for the renderer.

class zensols.calamr.render.base.rendergroup(renderer, graph_id='graph', display=True, directory=None)[source]

Bases: object

A context manager to render several graphs at a time, then optionally display them. Rendering graphs is done by calling an instance of this context manager.

Example:

with rendergroup(self.renderer) as render:
    render(graph, heading='Source Max flow')
__init__(renderer, graph_id='graph', display=True, directory=None)[source]

Initialize the context manager.

Parameters:
  • renderer (GraphRenderer) – used to render the graphs and optionally display using Renderer.display_all()

  • graph_id (str) – a unique identifier prefixed to files generated if none provided in the call method

  • display (bool) – whether to display the files after generated

  • directory (Path) – the directory to create the files in place of the temporary directory; if provided the directory is not removed after the graphs are rendered

zensols.calamr.render.graphvis module

Renderer AMR graphs using graphviz.

class zensols.calamr.render.graphvis.GraphVisGraphRenderer(browser_manager, extension='pdf', rooted=True, visual_style=<factory>, sleep=0)[source]

Bases: GraphRenderer

A graph renderer using graphviz.Digraph.

__init__(browser_manager, extension='pdf', rooted=True, visual_style=<factory>, sleep=0)
extension: str = 'pdf'

The output file’s extension.

zensols.calamr.render.plotly module

Renderer AMR graphs using plotly.

class zensols.calamr.render.plotly.PlotlyGraphRenderer(browser_manager, extension='html', rooted=True, visual_style=<factory>, sleep=0)[source]

Bases: GraphRenderer

Render teh graph in plotly using a tree layout with each separated on the Z-axis. This makes it easier to see each component separately and easier to follow where the component alignment lie.

To do this, the components have to be detached from the connected bipartite graph to be rendered separately. The alignment edges are then rendered afterwward.

__init__(browser_manager, extension='html', rooted=True, visual_style=<factory>, sleep=0)
extension: str = 'html'

The output file’s extension.

zensols.calamr.render.pyvis module

Renderer AMR graphs using pyvis.

class zensols.calamr.render.pyvis.PyvisGraphRenderer(browser_manager, extension='html', rooted=True, visual_style=<factory>, sleep=0)[source]

Bases: GraphRenderer

A graph renderer using the pyvis.network.Network API.

__init__(browser_manager, extension='html', rooted=True, visual_style=<factory>, sleep=0)
display(out_file)[source]

Display the graph generated in file out_file.

Parameters:

out_file (Path) – the graph to display

extension: str = 'html'

The output file’s extension.

zensols.calamr.render.util module

Utilities such as gradient color generators.

class zensols.calamr.render.util.ColorUtil[source]

Bases: object

static gradient_colors(n=10, rgb=0.5, end=1.0)[source]
static rainbow_colors(n=10, light=0.5, end=1.0)[source]
class zensols.calamr.render.util.Formatter(width=60, desc_width=500)[source]

Bases: object

__init__(width=60, desc_width=500)
coref_edge(edge)[source]
Return type:

Tuple[str]

desc_width: int = 500
edge(edge, ge, delim)[source]
Return type:

str

node(vertex, gn, delim)[source]
Return type:

str

width: int = 60