<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Hello,</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">The generate method only works if the semantic representations for the alternatives are subsumed by the input. These &quot;X verb Y Z&quot; vs &quot;X verb Z to Y&quot; alternatives should have equivalent semantics, but it in general it might not be the case that the *parsed* semantic representation is the one you want. In the code of my previous message note the line &quot;first_result = ...&quot;. At that point there may be other results (consider &quot;Kim gave their dog Rex&quot; (Kim gave Rex to their dog) vs &quot;Kim gave their dog Rex [to a loving home]&quot; (appositive; Rex is the dog); these would be separate parse results). So to be complete you can iterate over the results of parse_response as well as those of gen_response.</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">If you want to work with the derivation (parse) trees to find constituents and then use them to modify the surface sentence, here is some relevant information:</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">Documentation of PyDelphin&#39;s Derivation objects: <a href="https://pydelphin.readthedocs.io/en/latest/api/delphin.derivation.html">https://pydelphin.readthedocs.io/en/latest/api/delphin.derivation.html</a></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">General information about derivations: <a href="http://moin.delph-in.net/ItsdbDerivations">http://moin.delph-in.net/ItsdbDerivations</a></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Linguistic Type Database (LTDB): <a href="http://compling.hss.ntu.edu.sg/ltdb/ERG_1214//index.html">http://compling.hss.ntu.edu.sg/ltdb/ERG_1214//index.html</a></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">The LTDB link is for the ERG version 1214 as I don&#39;t think the 2018 version is up yet, but I think much of it may still be applicable. But better yet would be to browse parse results for the constructions you want, e.g., using <a href="http://erg.delph-in.net/">http://erg.delph-in.net/</a> or <a href="http://delph-in.github.io/delphin-viz/demo/">http://delph-in.github.io/delphin-viz/demo/</a>.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jul 3, 2019 at 4:34 AM Kelly, Matthew Alexander &lt;<a href="mailto:mak582@psu.edu">mak582@psu.edu</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">



<div style="overflow-wrap: break-word;">
My thanks to both of you.
<div><br>
</div>
<div>I managed to get both of your examples working.</div>
<div><br>
</div>
<div>Unfortunately, the generate function doesn’t reliably generate the prepositional object variation given the double object version of a sentence, or vice versa. Sometimes it only generates passive and active voice variations.</div>
<div><br>
</div>
<div>I think my best approach may be to not use the generate function and simply use the parse to identify the sentence structure and then swap the order of the NPs for the two objects, inserting or removing a “to” between the noun phrases as necessary.</div>
<div><br>
</div>
<div>Is there a reference page that explains the syntax of the parse tree and how to traverse it / manipulate it using Python, like in the <span style="font-family:arial,helvetica,sans-serif">def find_v_dat_dlr function below? </span><span style="font-family:arial,helvetica,sans-serif">I’d
 like to identify the boundaries of the two noun phrases at the end of each sentence.</span></div>
<div><br>
</div>
<div>Thanks again,</div>
<div><br>
</div>
<div>Matthew. <br>
<div>
<div dir="auto" style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<div dir="auto" style="overflow-wrap: break-word;">
<div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
-----</div>
<div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
Matthew A. Kelly, PhD</div>
<div dir="auto" style="overflow-wrap: break-word;">
E370 Westgate Building</div>
College of Information Science and Technology<br>
The Pennsylvania State University<br>
<br>
</div>
</div>
</div>
<div><br>
<blockquote type="cite">
<div>On Jul 2, 2019, at 6:05 AM, <a href="mailto:goodman.m.w@gmail.com" target="_blank">
goodman.m.w@gmail.com</a> wrote:</div>
<br class="gmail-m_-1909512159645347062Apple-interchange-newline">
<div>
<div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif"></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://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdelph-in%2Fpydelphin&amp;data=02%7C01%7Cmak582%40psu.edu%7C0e34b28ecb3042eb0fae08d6fef5ac78%7C7cf48d453ddb4389a9c1c115526eb52e%7C0%7C1%7C636976728463817227&amp;sdata=6%2BxKC68kO33f0z7fytf990MvM1Q50CZKM7zsbKeEJ%2Fs%3D&amp;reserved=0" target="_blank">https://github.com/delph-in/pydelphin</a>)
 and ACE (<a href="https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fsweaglesw.org%2Flinguistics%2Face%2F&amp;data=02%7C01%7Cmak582%40psu.edu%7C0e34b28ecb3042eb0fae08d6fef5ac78%7C7cf48d453ddb4389a9c1c115526eb52e%7C0%7C1%7C636976728463817227&amp;sdata=OF1T%2FnGoolWgTVbzkmi7bc30z%2FYkLkMrwvlm%2BAJ6rT8%3D&amp;reserved=0" target="_blank">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>
   <span class="gmail-m_-1909512159645347062Apple-converted-space"> </span><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-m_-1909512159645347062gmail-im"></span></div>
</div>
<div><br>
</div>
<div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif">This function could probably be improved but it seems to work for now.</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">Now if you want to parse a sentence, generate from its MRS, and inspect each derivation tree, you can do this:</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.interfaces import ace<br>
   <span class="gmail-m_-1909512159645347062Apple-converted-space"> </span><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 class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br>
</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif">    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 class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br>
</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Running this prints matching sentences and the token that went through the dative lexical rule.<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">    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 class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br>
</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif">I hope that is enough to get started.<br>
</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><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" target="_blank">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.<span class="gmail-m_-1909512159645347062Apple-converted-space"> </span><br>
<br>
I also found this page<span class="gmail-m_-1909512159645347062Apple-converted-space"> </span><a href="https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmoin.delph-in.net%2FAceUse&amp;data=02%7C01%7Cmak582%40psu.edu%7C0e34b28ecb3042eb0fae08d6fef5ac78%7C7cf48d453ddb4389a9c1c115526eb52e%7C0%7C1%7C636976728463827223&amp;sdata=n3Dd0CiyNZ2duvbWoMrlS%2B5RTPVYIE8%2BGHPK0mRoocM%3D&amp;reserved=0" 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<span class="gmail-m_-1909512159645347062Apple-converted-space"> </span><a href="https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpydelphin.readthedocs.io&amp;data=02%7C01%7Cmak582%40psu.edu%7C0e34b28ecb3042eb0fae08d6fef5ac78%7C7cf48d453ddb4389a9c1c115526eb52e%7C0%7C1%7C636976728463827223&amp;sdata=HVlQaWTvA1sm15eHVwOqTVnbE5jJimQJ7KyAON5gGPE%3D&amp;reserved=0" rel="noreferrer" target="_blank">http://pydelphin.readthedocs.io</a><span class="gmail-m_-1909512159645347062Apple-converted-space"> </span>may
 be easier to collect the outputs and control the interaction.<span class="gmail-m_-1909512159645347062Apple-converted-space"> </span><br>
<br>
<br>
Best,<br>
<br>
<br>
--<br>
Alexandre Rademaker<br>
<a href="https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Farademaker.github.io&amp;data=02%7C01%7Cmak582%40psu.edu%7C0e34b28ecb3042eb0fae08d6fef5ac78%7C7cf48d453ddb4389a9c1c115526eb52e%7C0%7C1%7C636976728463837219&amp;sdata=z2Nhvmnch%2BnU%2F8t5WNTb70Sgmqs5wBl4Zuwlr5k1txg%3D&amp;reserved=0" 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;<span class="gmail-m_-1909512159645347062Apple-converted-space"> </span><br>
&gt; in case anyone has time to respond to Matthew<br>
&gt;<span class="gmail-m_-1909512159645347062Apple-converted-space"> </span><br>
&gt;<span class="gmail-m_-1909512159645347062Apple-converted-space"> </span><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;<span class="gmail-m_-1909512159645347062Apple-converted-space"> </span><br>
&gt;<span class="gmail-m_-1909512159645347062Apple-converted-space"> </span><br>
&gt; Dear LinGO lab,<br>
&gt;<span class="gmail-m_-1909512159645347062Apple-converted-space"> </span><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;<span class="gmail-m_-1909512159645347062Apple-converted-space"> </span><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;<span class="gmail-m_-1909512159645347062Apple-converted-space"> </span><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;<span class="gmail-m_-1909512159645347062Apple-converted-space"> </span><br>
&gt; Thank you,<br>
&gt; Matthew.<br>
&gt;<span class="gmail-m_-1909512159645347062Apple-converted-space"> </span><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;<span class="gmail-m_-1909512159645347062Apple-converted-space"> </span><br>
<br>
<br>
</blockquote>
</div>
<br clear="all">
<br>
--<span class="gmail-m_-1909512159645347062Apple-converted-space"> </span><br>
<div dir="ltr" class="gmail-m_-1909512159645347062gmail_signature">-Michael Wayne Goodman</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>

</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature">-Michael Wayne Goodman</div>