Package: zensols.amr
AMR annotation and feature generationProvides support for AMR annotations and feature generation.Features:Annotation in AMR metadata.  For example, sentence types found in the Proxy
report AMR corpus.AMR token alignment asspaCycomponents.A scoring API that includesSmatchandWLK, which extends a more generalNLP scoring module.AMR parsing (amrlib) and AMR co-reference (amr_coref).Command line and API utilities for AMR graph Penman graphs, debugging and
files.Tools for training and evaluating AMR parse models.Documentationfull documentation.API referenceObtainingThe easiest way to install the command line program is via thepipinstaller:pip3installzensols.amrBinaries are also available onpypi.Usagefrompenman.graphimportGraphfromzensols.nlpimportFeatureDocument,FeatureDocumentParserfromzensols.amrimportAmrDocument,AmrSentence,ApplicationFactorysent:str="""He was George Washington and first president of the United States.He was born On February 22, 1732.""".replace('\n',' ').strip()# get the AMR document parserdoc_parser:FeatureDocumentParser=ApplicationFactory.get_doc_parser()# the parser creates a NLP centric feature document as provided in the# zensols.nlp packagedoc:FeatureDocument=doc_parser(sent)# the AMR object graph data structure is provided in the feature documentamr_doc:AmrDocument=doc.amr# dump a human readable output of the AMR documentamr_doc.write()# get the first AMR sentence instanceamr_sent:AmrSentence=amr_doc.sents[0]print('sentence:')print(' ',amr_sent.text)print('tuples:')# show the Penman graph representationpgraph:Graph=amr_sent.graphprint(f'variables:{", ".join(pgraph.variables())}')fortinpgraph.triples:print(' ',t)print('edges:')foreinpgraph.edges():print(' ',e)Per the example, thet5.confandgsii.confconfiguration show how to include
configuration needed per AMR model.  These files can also be used directly with
theamrcommand using the--configoption.However, the other resources in the example must be imported unless you
redefine them yourself.LibraryWhen adding theamrspaCy pipeline component, thedoc._.amrattribute is
set on theDocinstance.  You can either configure spaCy yourself, or you can
use the configuration files intest-resourcesas an example
using thezensols.util configuration framework.  The command line application
provides an example how to do this, along with thetest
case.Command LineThis library is written mostly to be used by other program, but the command
line utilityamris also available to demonstrate its usage and to generate
ARM graphs on the command line.To parse:$amrparse-ctest-resources/t5.conf'This is a test of the AMR command line utility.'# ::snt This is a test of the AMR command line utility.(t/test-01:ARG1(u/utility:mod(c/command-line):name(n/name:op1"AMR":toki1"6"):toki1"9"):domain(t2/this:toki1"0"):toki1"3")To generate graphs in PDF format:$amrplot-ctest-resources/t5.conf'This is a test of the AMR command line utility.'wrote:amr-graph/this-is-a-test-of-the-amr-comm.pdfPerformance (Smatch)This repo is configured to download and train on the AMR bio-medical corpus.
The results of the scores using amrlib's default smatch score is:CorpusModelPrecisionRecallF-scorebioamrlib t50.56136470228215420.47990297694707240.5174473330001563bioamrlib t5 + bio0.67921877591121430.61643726696786330.6463069704295633AttributionThis project, or reference model code, uses:Python 3spaCyfor natural language parsing.zensols.nlparsefor natural language features.amrlibfor AMR parsing.amr_coreffor AMR co-referenceSmatch(Cai and Knight. 2013) andWLK(Opitz et. al. 2021) for scoring.CitationIf you use this project in your research please use the following BibTeX entry:@inproceedings{landes-etal-2023-deepzensols,title="{D}eep{Z}ensols: A Deep Learning Natural Language Processing Framework for Experimentation and Reproducibility",author="Landes, Paul  andDi Eugenio, Barbara  andCaragea, Cornelia",editor="Tan, Liling  andMilajevs, Dmitrijs  andChauhan, Geeticka  andGwinnup, Jeremy  andRippeth, Elijah",booktitle="Proceedings of the 3rd Workshop for Natural Language Processing Open Source Software (NLP-OSS 2023)",month=dec,year="2023",address="Singapore, Singapore",publisher="Empirical Methods in Natural Language Processing",url="https://aclanthology.org/2023.nlposs-1.16",pages="141--146"}ChangelogAn extensive changelog is availablehere.CommunityPlease star this repository and let me know how and where you use this API.
Contributions as pull requests, feedback and any input is welcome.LicenseMIT LicenseCopyright (c) 2021 - 2023 Paul Landes