<div dir="ltr"><div style="font-family:arial,helvetica,sans-serif" class="gmail_default"></div><div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Hello Matthew,<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">I can offer a prototype using PyDelphin v0.9.2. The following Python 3 code assumes you have PyDelphin (<a href="https://github.com/delph-in/pydelphin">https://github.com/delph-in/pydelphin</a>) and ACE (<a href="http://sweaglesw.org/linguistics/ace/">http://sweaglesw.org/linguistics/ace/</a>) installed and a copy of the ERG .dat file (from ACE&#39;s website).<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">First, if you want to detect types in the syntax like &#39;v_dat_dlr&#39;, you probably want to look through the derivation tree. The following function descends through the tree and looks for the type:</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">    from delphin import derivation<br>    <br>    def find_v_dat_dlr(d):<br>        if isinstance(d, derivation.UdfNode):<br>            if d.entity == &#39;v_dat_dlr&#39;:<br>                return d.terminals()<br>            else:<br>                xs = []<br>                for dtr in d.daughters:<br>                    xs.extend(find_v_dat_dlr(dtr))<br>                return xs<br>        else:<br>            return []<br> <span class="gmail-im"></span></div></div><div><br></div><div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default">This function could probably be improved but it seems to work for now.</div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default"><br></div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default">Now if you want to parse a sentence, generate from its MRS, and inspect each derivation tree, you can do this:</div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default"><br></div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default">    from delphin.interfaces import ace<br>    <br>    grm = &#39;/home/mwg/grammars/erg-2018-x86-64-0.9.30.dat&#39;  # adjust as necessary<br>    sent = &#39;The gracious hostess offered the special guest her seat.&#39;<br>    parse_response = ace.parse(grm, sent)<br>    first_result = parse_response.result(0)<br>    mrs = first_result[&#39;mrs&#39;]</div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default"><br></div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default">    gen_response = ace.generate(grm, mrs)<br>    if gen_response:<br>        for result in gen_response.results():<br>            drv = result.derivation()<br>            dative_terminals = find_v_dat_dlr(drv)<br>            if dative_terminals:<br>                print(result[&#39;surface&#39;])<br>                print(&#39;  ({})&#39;.format(<br>                    &#39;, &#39;.join(tml.form for tml in dative_terminals)))<br>                print()</div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default"><br></div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default">Running this prints matching sentences and the token that went through the dative lexical rule.<br></div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default"><br></div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default">    Her seat was offered by the gracious hostess to the special guest.<br>      (offered)<br><br>    The gracious hostess offered her seat to the special guest.<br>      (offered)<br></div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default"><br></div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default">I hope that is enough to get started.<br></div><div style="font-family:arial,helvetica,sans-serif" class="gmail_default"><br></div></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 2, 2019 at 3:59 AM Alexandre Rademaker &lt;<a href="mailto:arademaker@gmail.com">arademaker@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Matthew,<br>
<br>
Maybe someone with more experience than me can add something here, but as far as I remember from the LREC tutorial in 2016, we can easily make a pipeline of two ACE calls. <br>
<br>
I also found this page <a href="http://moin.delph-in.net/AceUse" rel="noreferrer" target="_blank">http://moin.delph-in.net/AceUse</a><br>
<br>
<br>
$ cat test.txt<br>
The gracious hostess offered the special guest her seat.<br>
<br>
$ cat test.txt  | ~/hpsg/ace/ace -g ~/hpsg/ace/erg.dat -Tf1 | ~/hpsg/ace/ace -g ~/hpsg/ace/erg.dat -e<br>
NOTE: 1 readings, added 2940 / 844 edges to chart (306 fully instantiated, 210 actives used, 238 passives used) RAM: 7523k<br>
NOTE: parsed 1 / 1 sentences, avg 7523k, time 0.04242s<br>
Her seat was offered by the gracious hostess to the special guest.<br>
The gracious hostess offered her seat to the special guest.<br>
The special guest was offerred her seat by the gracious hostess.<br>
The gracious hostess offered the special guest her seat.<br>
NOTE: 1063 passive, 833 active edges in final generation chart; built 1264 passives total. [4 results]<br>
<br>
NOTE: generated 1 / 1 sentences, avg 13582k, time 0.10198s<br>
NOTE: transfer did 1025 successful unifies and 992 failed ones<br>
<br>
<br>
Using <a href="http://pydelphin.readthedocs.io" rel="noreferrer" target="_blank">http://pydelphin.readthedocs.io</a> may be easier to collect the outputs and control the interaction. <br>
<br>
<br>
Best,<br>
<br>
<br>
--<br>
Alexandre Rademaker<br>
<a href="http://arademaker.github.io" rel="noreferrer" target="_blank">http://arademaker.github.io</a><br>
<br>
<br>
&gt; On 1 Jul 2019, at 13:34, Ann Copestake &lt;<a href="mailto:aac10@cl.cam.ac.uk" target="_blank">aac10@cl.cam.ac.uk</a>&gt; wrote:<br>
&gt; <br>
&gt; in case anyone has time to respond to Matthew<br>
&gt; <br>
&gt; <br>
&gt; -------- Forwarded Message --------<br>
&gt; Subject:      Using the ERG for research<br>
&gt; Date: Fri, 28 Jun 2019 17:12:35 -0400<br>
&gt; From: Matthew Kelly &lt;<a href="mailto:mak582@psu.edu" target="_blank">mak582@psu.edu</a>&gt;<br>
&gt; To:   <a href="mailto:lingo@delph-in.net" target="_blank">lingo@delph-in.net</a><br>
&gt; <br>
&gt; <br>
&gt; Dear LinGO lab,<br>
&gt; <br>
&gt; I&#39;m a post-doctoral researcher at Penn State looking to use your ERG software package to convert a few thousand dative double object sentences into dative prepositional object sentences and vice versa.<br>
&gt; <br>
&gt; For example, I&#39;d like to convert the prepositional object sentence &quot;The gracious hostess offered her seat to the special guest.&quot; to the double object sentence &quot;The gracious hostess offered the special guest her seat.&quot;<br>
&gt; <br>
&gt; I am able to perform this conversion by using the online interface to &quot;analyze&quot; a sentence and then pressing &quot;generate&quot; to produce alternatives. How could I do this in batch, automatically?<br>
&gt; <br>
&gt; Thank you,<br>
&gt; Matthew.<br>
&gt; <br>
&gt; --<br>
&gt; Matthew A. Kelly, Ph.D.<br>
&gt; E370 Westgate Building<br>
&gt; College of Information Sciences and Technology<br>
&gt; The Pennsylvania State University<br>
&gt; <br>
<br>
<br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature">-Michael Wayne Goodman</div></div>