-
Notifications
You must be signed in to change notification settings - Fork 8
Visualization Tools
This page describes the AMR visualization tools in AMR-utils:
- Convert AMR graphs to Latex for paper writing (uses tikz library)
- Display AMR strings as HTML with optional display customization for tokens, nodes, and edges
- Compare two files of AMRs to find differences (for parser error analysis)
- Display AMR alignments for easy readability
AMR-utils allows you to read AMRs from a text file and output them as latex diagrams, such as the following.
The default coloring assigns blue to each node, but the parameter assign_color can be used to assign colors using a function. To change a color by hand, just rewrite \node[red] as \node[purple], etc.
Run as follows:
python style.py --latex -f [input file] [output file]
Add these lines to your latex file:
\usepackage{tikz}
\usetikzlibrary{shapes}
AMR-utils allows you to read AMRs from a text file and output them as html. You can look in style.css for an example of styling.
Run as follows:
python style.py --html -f [input file] [output file]
You can easily HTML_AMR.style(amrs) yourself to get a string of the HTML formatting. This function takes optional parameters assign_token_color, assign_node_color, and assign_edge_color to control color highlighting of tokens, nodes, and edges. Each parameter must be a function of the form f(amr, n, other_args) which returns a color term out of 'blue', 'red', 'green', and 'grey' or '' to leave the element unhighlighted. HTML_AMR.style() also takes optional parameters assign_token_desc, assign_node_desc, and assign_edge_desc which allow you to specify the mouse-over description text for a given token, node, or edge. See the code in display_alignments.py for an example of how to customize these parameters.
AMR Diff is a tool for comparing two files of AMRs. The tool uses AMR-to-AMR alignment from smatch to find the differences between pairs of AMRs which contribute to a lower smatch score. AMR Diff is useful for detailed error analysis of AMR parsers. The display includes highlighted node or edge mismatches and mouse-over description text for explaining each error.
Run as follows:
python amr_diff.py [amr file1] [amr file2] [output file]
AMR-utils also includes a tool for displaying alignments in an easy-to-read format, with highlights and mouse-over description text of which tokens/nodes/edges are aligned.
Run as follows:
python display_alignments.py [amr file] [alignment file] [output file]