<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
My thanks to both of you.
<div class=""><br class="">
</div>
<div class="">I managed to get both of your examples working.</div>
<div class=""><br class="">
</div>
<div class="">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 class=""><br class="">
</div>
<div class="">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 class=""><br class="">
</div>
<div class="">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&nbsp;<span style="font-family: arial, helvetica, sans-serif;" class="">def find_v_dat_dlr function below?&nbsp;</span><span style="font-family: arial, helvetica, sans-serif;" class="">I’d
 like to identify the boundaries of the two noun phrases at the end of each sentence.</span></div>
<div class=""><br class="">
</div>
<div class="">Thanks again,</div>
<div class=""><br class="">
</div>
<div class="">Matthew.&nbsp;<br class="">
<div class="">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div style="caret-color: rgb(0, 0, 0); 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; -webkit-text-stroke-width: 0px; text-decoration: none;">
-----</div>
<div style="caret-color: rgb(0, 0, 0); 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; -webkit-text-stroke-width: 0px; text-decoration: none;">
Matthew A. Kelly, PhD</div>
<div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
E370 Westgate Building</div>
College of Information Science and&nbsp;Technology<br class="">
The Pennsylvania State University<br class="">
<br class="">
</div>
</div>
</div>
<div><br class="">
<blockquote type="cite" class="">
<div class="">On Jul 2, 2019, at 6:05 AM, <a href="mailto:goodman.m.w@gmail.com" class="">
goodman.m.w@gmail.com</a> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" style="caret-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; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">
<div class="gmail_default" style="font-family: arial, helvetica, sans-serif;"></div>
<div dir="ltr" class="">
<div class="gmail_default" style="font-family: arial, helvetica, sans-serif;">Hello Matthew,<br class="">
</div>
<div class="gmail_default" style="font-family: arial, helvetica, sans-serif;"><br class="">
</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" originalsrc="https://github.com/delph-in/pydelphin" shash="jfvuR3JH5BGe9AoJPYzkjvuJMk8qLpT38B9WRfaY1kUlsmOQn/vA20F8QzBj7tmVVAkg0gDmbvcG1GzVLZhsqxs1B/3Qs4uYSjYIZu4DQ7Y4dBWUU/5r43qHVCw1&#43;oibx8t0E93g7r3g&#43;8gRptgOzOV2DMDmvUHx4BhkCvZMtKQ=" class="">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" originalsrc="http://sweaglesw.org/linguistics/ace/" shash="k40PI02mDkhfFk&#43;AEOccWWSRBiBsDsF9wKfQKnu7lhf&#43;BjXxBFlVyYxIlibVXQr21L6WkfXgAA/xtRjqgmoavk9wEQRsyFCH8OoKlh62fU/ShfK0Qv6EXpwWsTximl49EQMOSIrOzOSF1brciad8zp30EhOgc1BrMxt3Q7SLZOY=" class="">http://sweaglesw.org/linguistics/ace/</a>)
 installed and a copy of the ERG .dat file (from ACE's website).<br class="">
</div>
<div class="gmail_default" style="font-family: arial, helvetica, sans-serif;"><br class="">
</div>
<div class="gmail_default" style="font-family: arial, helvetica, sans-serif;">First, if you want to detect types in the syntax like 'v_dat_dlr', 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 class="">
</div>
<div class="gmail_default" style="font-family: arial, helvetica, sans-serif;">&nbsp; &nbsp; from delphin import derivation<br class="">
&nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span><br class="">
&nbsp; &nbsp; def find_v_dat_dlr(d):<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; if isinstance(d, derivation.UdfNode):<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if d.entity == 'v_dat_dlr':<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return d.terminals()<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else:<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xs = []<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for dtr in d.daughters:<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xs.extend(find_v_dat_dlr(dtr))<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return xs<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; else:<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return []<br class="">
<span class="gmail-im"></span></div>
</div>
<div class=""><br class="">
</div>
<div class="">
<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 class="">
</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 class="">
</div>
<div class="gmail_default" style="font-family: arial, helvetica, sans-serif;">&nbsp; &nbsp; from delphin.interfaces import ace<br class="">
&nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span><br class="">
&nbsp; &nbsp; grm = '/home/mwg/grammars/erg-2018-x86-64-0.9.30.dat'&nbsp; # adjust as necessary<br class="">
&nbsp; &nbsp; sent = 'The gracious hostess offered the special guest her seat.'<br class="">
&nbsp; &nbsp; parse_response = ace.parse(grm, sent)<br class="">
&nbsp; &nbsp; first_result = parse_response.result(0)<br class="">
&nbsp; &nbsp; mrs = first_result['mrs']</div>
<div class="gmail_default" style="font-family: arial, helvetica, sans-serif;"><br class="">
</div>
<div class="gmail_default" style="font-family: arial, helvetica, sans-serif;">&nbsp; &nbsp; gen_response = ace.generate(grm, mrs)<br class="">
&nbsp; &nbsp; if gen_response:<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; for result in gen_response.results():<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; drv = result.derivation()<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dative_terminals = find_v_dat_dlr(drv)<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if dative_terminals:<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print(result['surface'])<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print(' &nbsp;({})'.format(<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ', '.join(tml.form for tml in dative_terminals)))<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print()</div>
<div class="gmail_default" style="font-family: arial, helvetica, sans-serif;"><br class="">
</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 class="">
</div>
<div class="gmail_default" style="font-family: arial, helvetica, sans-serif;"><br class="">
</div>
<div class="gmail_default" style="font-family: arial, helvetica, sans-serif;">&nbsp;&nbsp;&nbsp; Her seat was offered by the gracious hostess to the special guest.<br class="">
&nbsp; &nbsp; &nbsp; (offered)<br class="">
<br class="">
&nbsp;&nbsp;&nbsp; The gracious hostess offered her seat to the special guest.<br class="">
&nbsp; &nbsp; &nbsp; (offered)<br class="">
</div>
<div class="gmail_default" style="font-family: arial, helvetica, sans-serif;"><br class="">
</div>
<div class="gmail_default" style="font-family: arial, helvetica, sans-serif;">I hope that is enough to get started.<br class="">
</div>
<div class="gmail_default" style="font-family: arial, helvetica, sans-serif;"><br class="">
</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" class="">arademaker@gmail.com</a>&gt; wrote:<br class="">
</div>
<blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">
Hi Matthew,<br class="">
<br class="">
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="Apple-converted-space">&nbsp;</span><br class="">
<br class="">
I also found this page<span class="Apple-converted-space">&nbsp;</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" originalsrc="http://moin.delph-in.net/AceUse" shash="i6U5U/TUEqT9Ze8JoLor02uzYPaaeCbX2qnEFIP&#43;/eRDWFvOMkxgJ2Yk4by2209qTNpNX8Jp5UbmxSVV/IENOgu6ROCP/ENGZRZoJSujDJq21pQzYCj8VASBgzH2wSlAS4&#43;DdR2qflWtw039etlmPyrAxKAMqG247zcqJi6HMdA=" rel="noreferrer" target="_blank" class="">http://moin.delph-in.net/AceUse</a><br class="">
<br class="">
<br class="">
$ cat test.txt<br class="">
The gracious hostess offered the special guest her seat.<br class="">
<br class="">
$ cat test.txt&nbsp; | ~/hpsg/ace/ace -g ~/hpsg/ace/erg.dat -Tf1 | ~/hpsg/ace/ace -g ~/hpsg/ace/erg.dat -e<br class="">
NOTE: 1 readings, added 2940 / 844 edges to chart (306 fully instantiated, 210 actives used, 238 passives used) RAM: 7523k<br class="">
NOTE: parsed 1 / 1 sentences, avg 7523k, time 0.04242s<br class="">
Her seat was offered by the gracious hostess to the special guest.<br class="">
The gracious hostess offered her seat to the special guest.<br class="">
The special guest was offerred her seat by the gracious hostess.<br class="">
The gracious hostess offered the special guest her seat.<br class="">
NOTE: 1063 passive, 833 active edges in final generation chart; built 1264 passives total. [4 results]<br class="">
<br class="">
NOTE: generated 1 / 1 sentences, avg 13582k, time 0.10198s<br class="">
NOTE: transfer did 1025 successful unifies and 992 failed ones<br class="">
<br class="">
<br class="">
Using<span class="Apple-converted-space">&nbsp;</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" originalsrc="http://pydelphin.readthedocs.io" shash="r/9pOrtPkRkNg/tfZzKzuHtEahUZ5GOW&#43;8tqsLt2v9bhyUM3nwIRtoFINFlFRsGdhNf2jpVvwNf9daQ2m8Bqesh23Wa0DV3l9psZWzSuhif2HRPKFi8WTe6nIm4&#43;hryIdWeC8Weftu9LsE4NWV/d6iwx1OsPd8Lt79fXlyBuX4s=" rel="noreferrer" target="_blank" class="">http://pydelphin.readthedocs.io</a><span class="Apple-converted-space">&nbsp;</span>may
 be easier to collect the outputs and control the interaction.<span class="Apple-converted-space">&nbsp;</span><br class="">
<br class="">
<br class="">
Best,<br class="">
<br class="">
<br class="">
--<br class="">
Alexandre Rademaker<br class="">
<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" originalsrc="http://arademaker.github.io" shash="UH8TtvBFf5RDS6QmZ88l0o4IeacVoMKmEXvGOlilokMvD5Z3gJVs8C/N&#43;53IyIi7MMfth42A77JohjmyXVMpydlPUAxGvmat2rUMfc&#43;XE/nx2CNI7e9V0apSr/FrEkqBTw8AnpmHnUueWwUAQzAcXCuJDtgeBHfW9uDwQSJIFZE=" rel="noreferrer" target="_blank" class="">http://arademaker.github.io</a><br class="">
<br class="">
<br class="">
&gt; On 1 Jul 2019, at 13:34, Ann Copestake &lt;<a href="mailto:aac10@cl.cam.ac.uk" target="_blank" class="">aac10@cl.cam.ac.uk</a>&gt; wrote:<br class="">
&gt;<span class="Apple-converted-space">&nbsp;</span><br class="">
&gt; in case anyone has time to respond to Matthew<br class="">
&gt;<span class="Apple-converted-space">&nbsp;</span><br class="">
&gt;<span class="Apple-converted-space">&nbsp;</span><br class="">
&gt; -------- Forwarded Message --------<br class="">
&gt; Subject:&nbsp; &nbsp; &nbsp; Using the ERG for research<br class="">
&gt; Date: Fri, 28 Jun 2019 17:12:35 -0400<br class="">
&gt; From: Matthew Kelly &lt;<a href="mailto:mak582@psu.edu" target="_blank" class="">mak582@psu.edu</a>&gt;<br class="">
&gt; To:&nbsp; &nbsp;<a href="mailto:lingo@delph-in.net" target="_blank" class="">lingo@delph-in.net</a><br class="">
&gt;<span class="Apple-converted-space">&nbsp;</span><br class="">
&gt;<span class="Apple-converted-space">&nbsp;</span><br class="">
&gt; Dear LinGO lab,<br class="">
&gt;<span class="Apple-converted-space">&nbsp;</span><br class="">
&gt; I'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 class="">
&gt;<span class="Apple-converted-space">&nbsp;</span><br class="">
&gt; For example, I'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 class="">
&gt;<span class="Apple-converted-space">&nbsp;</span><br class="">
&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 class="">
&gt;<span class="Apple-converted-space">&nbsp;</span><br class="">
&gt; Thank you,<br class="">
&gt; Matthew.<br class="">
&gt;<span class="Apple-converted-space">&nbsp;</span><br class="">
&gt; --<br class="">
&gt; Matthew A. Kelly, Ph.D.<br class="">
&gt; E370 Westgate Building<br class="">
&gt; College of Information Sciences and Technology<br class="">
&gt; The Pennsylvania State University<br class="">
&gt;<span class="Apple-converted-space">&nbsp;</span><br class="">
<br class="">
<br class="">
</blockquote>
</div>
<br clear="all" class="">
<br class="">
--<span class="Apple-converted-space">&nbsp;</span><br class="">
<div dir="ltr" class="gmail_signature">-Michael Wayne Goodman</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>