ERG's MRS output as LaTeX

erg

#1

What’s current best way to obtain MRS representations from ERG in LaTeX? The ERG’s own function does not immediately work for me, either I am using it incorrectly (I am copying and pasting the output into my LaTeX document and include the mrs.sty package) or something in that code is outdated.

Is there something in delphinviz? The demo only offers an image, I think.


#2

For my dissertation I used the output from the LKB to get the basic LaTeX commands, but I ended up tweaking the code myself and modifying mrs.sty to get it to look right. I think I added just the following to mrs.sty:

\newcommand{\miblock}[4]{%
  \ensuremath{
  \left \langle
  \begin{array}{l}
      #1,#2,\\
      \left \{ {\begin{array}{l}#3\end{array}} \right \},\\
      \lbrace #4 \rbrace \\
    \end{array}
  \right \rangle
}
}

Then here’s how I call it for the MRS for “Every dog chased some cat”:

\begin{exe}
  \small
  \ex \label{ex:edcsc-3b}
  \miblock{\sh{1}}{\svar{e}{3}{}}{%
  \sep{\sh{4}}{\spred{\_every\_q\slnkc{0}{5}}}{%
    \srole{ARG0}{\svar{x}{6}{\svp{PERS}{3}, \svp{NUM}{sg}, \svp{IND}{$+$}}},
    \srole{RSTR}{\svar{h}{7}{}},
    \srole{BODY}{\svar{h}{5}{}}},\\
  \sep{\sh{8}}{\spred{\_dog\_n\_1\slnkc{6}{9}}}{%
    \srole{ARG0}{\svar{x}{6}{}}},\\
  \sep{\sh{2}}{\spred{\_chase\_v\_1\slnkc{10}{16}}}{%
    \srole{ARG0}{\svar{e}{3}{\svp{SF}{prop}, \svp{TENSE}{past}, \svp{MOOD}{indicative}, \svp{PROG}{$-$}, \svp{PERF}{$-$}}},\\
    \srole{ARG1}{\svar{x}{6}{}},\\
    \srole{ARG2}{\svar{x}{9}{\svp{PERS}{3}, \svp{NUM}{sg}, \svp{IND}{$+$}}}},\\
  \sep{\sh{10}}{\spred{\_some\_q\_indiv\slnkc{17}{21}}}{%
    \srole{ARG0}{\svar{x}{9}{}},
    \srole{RSTR}{\svar{h}{12}{}},
    \srole{BODY}{\svar{h}{11}{}}},\\
  \sep{\sh{13}}{\spred{\_cat\_n\_1\slnkc{22}{26}}}{%
    \srole{ARG0}{\svar{x}{9}{}}}}
  {\sqeq{12}{13}, \sqeq{7}{8}, \sqeq{1}{2}}
\end{exe}

delphinviz only offers an image in the Simple MRS pseudo-feature-structure visualization, not the indexed Simple MRS visualization that is produced by mrs.sty. I would like PyDelphin to have an mrs-latex conversion target like it has dmrs-tikz, but it does not currenly provide this. It would actually be fairly simple to implement, but I was hoping to also provide a replacement for mrs.sty, and this takes a bit more effort.


#3

I used the code below to output mrs into my emacs buffer when using the lkb. I can’t remember why I preferred this to LUI.

I think you can also save latex from LUI: http://moin.delph-in.net/LkbTex

;;;

;;; Output latex in emacs

;;; turn on with (setf mrs-latex-output-p t)

(in-package :mrs)

(defvar mrs-latex-output-p nil)

(defun output-mrs-after-parse (&optional edges stream)

;;; for ACL this is most likely to be useful in an emacs window

;;; the need to use lkb-background-stream is because

;;; of the complexity with background streams in ACL

;;; it’s set in topmenu.lsp

(when (or mrs-scoping-output-p

mrs-base-output-p

rmrs-xml-output-p

rmrs-compact-output-p

    *mrs-discourse*

    *mrs-latex-output-p*)

(unless stream

(setf stream lkb::lkb-background-stream))

(unless edges (setf edges parse-record))

(let ((print-circle nil))

(loop for edge in edges

do

(let ((mrs (extract-mrs edge)))

(format stream “~%Edge number ~A”

(lkb::edge-id edge))

(format stream “~%~A~%”

(lkb::parse-tree-structure edge))

(treat-mrs mrs t stream))))))

(defun mrs::treat-mrs (mrs-struct simplep stream)

(format stream "~%~A " lkb::sentence)

(setf mrs-debug mrs-struct)

(when mrs-base-output-p

(output-mrs1 mrs-struct 'simple stream))

(when mrs-scoping-output-p

(process-mrs-struct mrs-struct nil 10 simplep stream))

(when mrs-fol-output-p

(output-fol-approximation mrs-struct stream))

(when rmrs-xml-output-p

(output-rmrs1 (mrs-to-rmrs mrs-struct) 'xml stream))

(when mrs-latex-output-p

(mrs::output-mrs1 mrs-struct 'mrs::latex stream))

(when rmrs-compact-output-p

(output-rmrs1 (mrs-to-rmrs mrs-struct) 'compact stream t))

(when mrs-discourse

 (output-mrs1 mrs-struct 'simple stream)

 (output-mrs1 mrs-struct 'prolog stream)

 (with-open-file (pro-out "~/tmp/prologformat"

		  :direction :output :if-does-not-exist :create

		  :if-exists :append)

   (output-mrs1 mrs-struct 'prolog pro-out))))