Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


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.

Running GoPhi

Using the web interface at RALI

  • browse GoPhi to edit an AMR that can be verbalized

Using the web interface with the internal SWI-Prolog web server

  • Launch the SWI-Prolog console and type the commands at the ?- prompt not forgetting to end with a full stop. Wait for the true. reply from the Prolog interpreter.

From the SWI-Prolog console

  • 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 the true. reply from the Prolog interpreter.

    • Load the system


    • Verbalize a single AMR in a string (showing intermediary information).

      For example:
      testAMRstring('(s / say-01 :ARG0 (i/I) :ARG1 (h/hello) :ARG2 (w/world))').

      it should return

        > Semantic Representation
        > Deep Syntactic Representation
        > Surface Syntactic Representation
        > 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


      where ShowStructs and TraceTrans 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 structures
      • traceAMRstring(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.


      For example, to process AMRs with at least an inverse role:

    • 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.


File organization of GoPhi

Prolog (.pl) files (build directory)


  • AMR → Semantic Representation (SemR)

    • : parse with error messages in the case of a malformed AMR
    • : parse that takes for granted that AMR are well-formed, fails otherwise
    • : utilities for parsing and pretty-printing
    • : transformation of inverse roles in the SemR
  • AMR → First-Order Logic

    • : transformation into FOL using the algorithm of Bos
  • AMR → English

    • : simplistic baseline generator
  • Semantic Representation → Deep Syntactic Representation (DSyntR)

    • : basic transformations into DSyntR
    • : generate an appropriate pronominal reference
    • : deal with most of the roles
    • : deal with some special concepts
  • Deep Syntactic Representation → Surface Syntactic Representation (SSurfR)

    • : DCG for creating a jsRealB expression


  • : auxiliary predicates for the dictionary
  • : automatically generated dictionary using tools/createPrologDico that parses PropBank frames and add missing from the jsRealB lexicon
  • : additions and corrections to
  • gender associated with some English words, created by tools/

Driving the whole process:

  • : transforms a single AMR to an English sentence using the predicates:
    • amr2SSyntR/4 is the main predicate for transformation
    • parseFile/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 call
    • start/0 parses command line arguments to drive the transformation, calls the transformation, keeping full trace in *.amr2engtrace, calls tools/ to compute statistics and create an Excel file for development evaluation
  • : Extracts AMR strings from a file in LDC format and generates an English sentence for each

Web application

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.

  • : creates a web page with an embedded editor that contains an AMR with checkboxes for selecting the intermediary structures to show.
  • : creates a web page showing the original AMR, the selected representations and the English realization. The generated web page loads gophi-web/jsRealB.min.js and gophi-web/addLexicon-dme.js which realizes the English sentence.
  • : shows the input page with either an initial AMR or the current one
  • : parses the AMR (using 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 directory
    • addLexicon-dme.js : load big lexicon lexicon-dme.json and make some local modifications
    • amr-verb.css : CSS for the generated web pages
    • amr-verb.js : javascript for use in the generated web pages
    • jsRealB.min.js : minifyed jsRealB that generates from the SSurfR
    • lexicon-dme.json : big lexicon in json format
  • makefile : compiles two CGis from and and moves them to a directory that an Apache server can use (compilation is not mandatory but it improves the efficiency of the system)
  • : 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.


  • : a few examples as Prolog terms taken from articles and useful for testing without parsing a file
  • : 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)

Informations (documentation directory)

  • GenAMR.pdf : paper describing the rationale and design of gophi
  • : recipes for getting and running three AMR generators and producing a spreadsheet for comparative evaluation

Shell scripts (scripts directory)

  • gophiFile : calls with appropriate arguments
  • gophiDir: calls gophiFile on all amr*.txt files in a given directory and keeps a copy of stdout in *.amrtoengtrace files
  • compareOutput : calls compareGoPhiOutputs.pyon oldfile and newFile given as parameters

Python files (tools directory)

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.

  • create from data/englishGenderWords.txt
  • : compute statistics of occurrences of concepts found (or not) in PropBank
  • : 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 filter
  • : parses .out files, computes BLEU scores and creates an Excel file for manual evaluation
  • : used by
  • : compare the outputs (i.e. out files) of two runs on the same examples and output the differences between them
  • : from a file containing many AMRs, generate a sample AMR file of appropriate format for gophi, isiMT and jamr more info
  • : creates a comparative evaluation spreadsheet from the output of gophi, isiMT and jamr more info
  • : parses PropBank frames and jsRealB lexicon to create
  • : unfinished (and thus unused) attempt to replace regex with DCG
  • : used by to display the difference between two strings

AMR files

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

Data file extensions

  • *.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

Guy Lapalme


GOPHI: an AMR-to-English Verbalizer






No releases published


No packages published