GOPHI (Generation Of Parenthesized Human Input) is a system for generating a literal reading of Abstract Meaning Representation (AMR) structures. The system, written in SWI-Prolog, uses a symbolic approach to transform the original rooted graph into a tree of constituents that is transformed into an English sentence by jsRealB.
More information about the design and the rationale of the system in this paper.
- browse GoPhi to edit an AMR that can be verbalized
-
Launch the SWI-Prolog console and type the commands at the
?-
prompt not forgetting to end with a full stop. Wait for thetrue.
reply from the Prolog interpreter.-
Load the system
cd('/path/to/the/build/directory').
[gophiWeb].
-
In a web browser, browse : http://127.0.0.1:8000/amrVerbalizer to edit an AMR that can be verbalized
-
-
Launch the jsRealB interpreter in another window/process
node /path/to/jsRealB/server-dme.js
-
Launch the SWI-Prolog console and type the commands at the
?-
prompt not forgetting to end with a full stop. Wait for thetrue.
reply from the Prolog interpreter.-
Load the system
cd('/path/to/the/build/directory').
[gophiFile].
-
Verbalize a single AMR in a string (showing intermediary information).
testAMRstring(AMRstring).
For example:
testAMRstring('(s / say-01 :ARG0 (i/I) :ARG1 (h/hello) :ARG2 (w/world))').
it should return
> Semantic Representation ['say-01',s, [':ARG0',['I',i]], [':ARG1',[hello,h]], [':ARG2',[world,w]]] > Deep Syntactic Representation s(pro("I")*pe(1)*g("m")*n("s"), vp(v("say"), np($(null)/d("the"), null, n("hello")), non-null/pp(p("to"), np($(null)/d("the"), null, n("world"))), null/pp(p("of"), null))) > Surface Syntactic Representation S(Pro("I").pe(1).g("m").n("s"), VP(V("say"), NP(D("the"), N("hello")), PP(P("to"), NP(D("the"), N("world"))))) > English sentence I say the hello to the world.
-
Verbalize a single AMR in a string, controlling output of structure and enabling the tracing of the transformation into DSyntR
amr2SSyntR(AMRstring,SSyntR,ShowStructs,TraceTrans)
where
ShowStructs
andTraceTrans
are boolean, for example:amr2SSyntR('(s / say-01 :ARG0 (i/I) :ARG1 (h/hello) :ARG2 (w/world))',SSyntR,true,false).
These calls can be simplified with
testAMRstring(AMRstring)
: shows all intermediary structurestraceAMRstring(AMRstring)
: enables tracing of AMR to DSyntR
-
Show the input AMRs in a file that match a
Regex
(which can be '' to match all AMRs) and their English realization.Regex
can also be a number (usually between 0 and 1) that indicates the probability that the current AMR is processed. This is not equivalent to a random sampling, but it is enough for our testing purpose.showRealisation(InFileName,Regex).
For example, to process AMRs with at least an inverse role:
showRealisation('../amr-examples/amr-examples.txt',':ARG.-of').
-
Show the input AMRs in a file that match a
Regex
(which can be '' to match all AMRs) and display the intermediary structures leading to their English realization.showAMRsFile(InFileName,Regex).
-
-
AMR → Semantic Representation (SemR)
checkParse.pl
: parse with error messages in the case of a malformed AMRparse.pl
: parse that takes for granted that AMR are well-formed, fails otherwiseutils.pl
: utilities for parsing and pretty-printinginverseRoles.pl
: transformation of inverse roles in the SemR
-
AMR → First-Order Logic
semantics.pl
: transformation into FOL using the algorithm of Bos
-
AMR → English
baselineGen.pl
: simplistic baseline generator
-
Semantic Representation → Deep Syntactic Representation (DSyntR)
deepSyntR.pl
: basic transformations into DSyntRpronounReference.pl
: generate an appropriate pronominal referenceroles.pl
: deal with most of the rolesspecialConcept.pl
: deal with some special concepts
-
Deep Syntactic Representation → Surface Syntactic Representation (SSurfR)
surfSyntR.pl
: DCG for creating a jsRealB expression
dictionary-utils.pl
: auxiliary predicates for the dictionarydictionaryGenerated.pl
: automatically generated dictionary usingtools/createPrologDico
that parses PropBank frames and add missing from the jsRealB lexicondictionary.pl
: additions and corrections todictionaryGenerated.pl
gender.pl
: gender associated with some English words, created bytools/addGender.py
gophi.pl
: transforms a single AMR to an English sentence using the predicates:amr2SSyntR/4
is the main predicate for transformationparseFile/4
parses all AMRs in a file (with a possible selection via regex)jsRealB/2
either calls a server process or launches one at each callstart/0
parses command line arguments to drive the transformation, calls the transformation, keeping full trace in*.amr2engtrace
, callstools/amrStats.py
to compute statistics and create an Excel file for development evaluation
gophiFile.pl
: Extracts AMR strings from a file in LDC format and generates an English sentence for each
A CGI that creates a web page in which a user can edit an AMR, which is then transformed and realised by jsRealB in that same web page.
inputPage.pl
: creates a web page with an embedded editor that contains an AMR with checkboxes for selecting the intermediary structures to show.replyPage.pl
: creates a web page showing the original AMR, the selected representations and the English realization. The generated web page loadsgophi-web/jsRealB.min.js
andgophi-web/addLexicon-dme.js
which realizes the English sentence.amrVerbalizer.pl
: shows the input page with either an initial AMR or the current oneamrGenerate.pl
: parses the AMR (usingcheckParse.pl
) if it detects errors it displays the input page with error messages; if there are no errors, then it realizes the AMR and displays the intermediary structures that the user has chosen when submitting the form.gophi-web
directoryaddLexicon-dme.js
: load big lexiconlexicon-dme.json
and make some local modificationsamr-verb.css
: CSS for the generated web pagesamr-verb.js
: javascript for use in the generated web pagesjsRealB.min.js
: minifyed jsRealB that generates from the SSurfRlexicon-dme.json
: big lexicon in json format
makefile
: compiles two CGis fromamrVerbalizer.pl
andamrGenerate.pl
and moves them to a directory that an Apache server can use (compilation is not mandatory but it improves the efficiency of the system)gophiWeb.pl
: a version of the web application that uses the internal SWI-Prolog web server. It is appropriate for developing on a single machine, but at RALI we use the CGIs.
examples.pl
: a few examples as Prolog terms taken from articles and useful for testing without parsing a fileunitTests.pl
: a small set-up for testing with a few examples::- testAll.
: test all examples and compare with the expected string (i.e. produced by a previous version)
GenAMR.pdf
: paper describing the rationale and design ofgophi
ComparativeEvaluation.md
: recipes for getting and running three AMR generators and producing a spreadsheet for comparative evaluation
gophiFile
: callsgophiFile.pl
with appropriate argumentsgophiDir
: callsgophiFile
on allamr*.txt
files in a given directory and keeps a copy of stdout in*.amrtoengtrace
filescompareOutput
: callscompareGoPhiOutputs.py
on oldfile and newFile given as parameters
Caution: some of these programs use files that are not available in this distribution because they are not in public domain (e.g. AMRs 2.0 from LDC) or that should be downloaded from the AMR homepage.
addGender.py
: creategender.pl
fromdata/englishGenderWords.txt
amrConceptsVSPropBankNLexicon.py
: compute statistics of occurrences of concepts found (or not) in PropBankamrIndent.py
: indent an AMR read from stdin, taking into account the parentheses level and starting a new line at each role, intended to be used as a filteramrStats.py
: parses.out
files, computes BLEU scores and creates an Excel file for manual evaluationcalculatebleu.py
: used by amrStats.pycompareGoPhiOutputs.py
: compare the outputs (i.e. out files) of two runs on the same examples and output the differences between themcreateEvalFiles.py
: from a file containing many AMRs, generate a sample AMR file of appropriate format forgophi
,isiMT
andjamr
more infocreateEvalSpreadsheet.py
: creates a comparative evaluation spreadsheet from the output ofgophi
,isiMT
andjamr
more infocreatePrologDico.py
: parses PropBank frames and jsRealB lexicon to createdictionaryGenerated.pl
dcg_regex.pl
: unfinished (and thus unused) attempt to replace regex with DCGlevenshtein.py
: used bycompareGoPhiOutputs.py
to display the difference between two strings
Text files containing AMRs for developing and testing in three directories:
abstract_meaning_representation_amr_2.0
: should be filled with content downloaded from LDC.amr-examples
: examples gathered for developing GOPHI:- amr-examples.txt : simple examples gathered from different papers
- amr-dict-examples.txt : examples extracted from the AMR dictionary
- amr-guidelines-1_2_5.txt : examples extracted from the AMR Guidelines
amr-ISI
: examples to be downloaded from the ISI download page
*.txt
: input AMRs*.out
: input AMRs augmented with output of gophi and baselinegen*.amr2engtrace
: full trace of the output of the transformation of a .txt file*.xlsx
: Excel file (AMR, Basegen, reference sent, gophi output) for development or comparative evaluation, conventionally we add information about the evaluator before.xlsx