Package: amrlib
amrlibA python library that makes AMR parsing, generation and visualization simple.For the latest documentation, seeReadTheDocs.!! Note:The models must be downloaded and installed separately.  See theInstallation Instructions.Aboutamrlib is a python module designed to make processing forAbstract Meaning Representation(AMR) simple by providing the following functionsSentence to Graph (StoG) parsing to create AMR graphs from English sentences.Graph to Sentence (GtoS) generation for turning AMR graphs into English sentences.A QT based GUI to facilitate conversion of sentences to graphs and back to sentencesMethods to plot AMR graphs in both the GUI and as library functionsTraining and test code for both the StoG and GtoS models.ASpaCyextension that allows direct conversion of
SpaCyDocsandSpansto AMR graphs.Sentence to Graph alignment routinesFAA_Aligner (Fast_Align Algorithm), based on the ISI aligner code detailed in thispaper.RBW_Aligner (Rule Based Word) for simple, single token to single node alignmentAn evaluation metric API including including...Smatch (multiprocessed with enhanced/detailed scores) for graph parsingsee note at the bottom about smatch scoringBLEU for sentence generationAlignment scoring metrics detailing precision/recallAMR ModelsThe system includes different neural-network models for parsing and for generation.!! Note:Models must be downloaded and installed separately.
Seeamrlib-modelsfor all parse and generate model download links.Parse (StoG) model_parse_xfm_bart_large gives an83.7 SMATCH scorewith LDC2020T02.For a technical description of the parse model see itswiki-pageGeneration (GtoS) generate_t5wtense gives a54 BLEUwith tense tags or44 BLEUwith un-tagged LDC2020T02.AMR ViewThe GUI allows for simple viewing, conversion and plotting of AMR Graphs.AMR CoReference ResolutionThe library does not contain code for AMR co-reference resolution but there is a related project
atamr_coref.The following papers have GitHub projects/code that have similar or better scoring than the above..VGAE as Cheap Supervision for AMR Coreference ResolutionEnd-to-end AMR Coreference ResolutionRequirements and InstallationThe project was built and tested under Python 3 and Ubuntu but should run on any Linux, Windows, Mac, etc.. system.SeeInstallation Instructionsfor details on setup.Library UsageTo convert sentences to graphsimport amrlib
stog = amrlib.load_stog_model()
graphs = stog.parse_sents(['This is a test of the system.', 'This is a second sentence.'])
for graph in graphs:
    print(graph)To convert graphs to sentencesimport amrlib
gtos = amrlib.load_gtos_model()
sents, _ = gtos.generate(graphs)
for sent in sents:
    print(sent)For a detailed description see theModel API.Usage as a Spacy ExtensionTo use as an extension, you need spaCy version 2.0 or later.  To setup the extension and use it do the followingimport amrlib
import spacy
amrlib.setup_spacy_extension()
nlp = spacy.load('en_core_web_sm')
doc = nlp('This is a test of the SpaCy extension. The test has multiple sentences.')
graphs = doc._.to_amr()
for graph in graphs:
    print(graph)For a detailed description see theSpacy API.ParaphrasingFor an example of how to use the library to do paraphrasing, see theParaphrasingsection in the docs.SMATCH Scoringamrlib uses thesmatchlibrary for scoring.
This is the library that is most commonly used for scoring AMR parsers and reporting results in literature.
There are some cases where the code may give inconsistant or erroneous results.
You may wish to look atsmatchppfor an improved scoring algorithm.IssuesIf you find a bug, please report it on theGitHub issues list.
Additionally, if you have feature requests or questions, feel free to post there as well.  I'm happy to
consider suggestions and Pull Requests to enhance the functionality and usability of the module.