<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'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 '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></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 == 'v_dat_dlr':<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 = '/home/mwg/grammars/erg-2018-x86-64-0.9.30.dat' # adjust as necessary<br> sent = 'The gracious hostess offered the special guest her seat.'<br> parse_response = ace.parse(grm, sent)<br> first_result = parse_response.result(0)<br> mrs = first_result['mrs']</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['surface'])<br> print(' ({})'.format(<br> ', '.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 <<a href="mailto:arademaker@gmail.com">arademaker@gmail.com</a>> 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>
> On 1 Jul 2019, at 13:34, Ann Copestake <<a href="mailto:aac10@cl.cam.ac.uk" target="_blank">aac10@cl.cam.ac.uk</a>> wrote:<br>
> <br>
> in case anyone has time to respond to Matthew<br>
> <br>
> <br>
> -------- Forwarded Message --------<br>
> Subject: Using the ERG for research<br>
> Date: Fri, 28 Jun 2019 17:12:35 -0400<br>
> From: Matthew Kelly <<a href="mailto:mak582@psu.edu" target="_blank">mak582@psu.edu</a>><br>
> To: <a href="mailto:lingo@delph-in.net" target="_blank">lingo@delph-in.net</a><br>
> <br>
> <br>
> Dear LinGO lab,<br>
> <br>
> 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>
> <br>
> For example, I'd like to convert the prepositional object sentence "The gracious hostess offered her seat to the special guest." to the double object sentence "The gracious hostess offered the special guest her seat."<br>
> <br>
> I am able to perform this conversion by using the online interface to "analyze" a sentence and then pressing "generate" to produce alternatives. How could I do this in batch, automatically?<br>
> <br>
> Thank you,<br>
> Matthew.<br>
> <br>
> --<br>
> Matthew A. Kelly, Ph.D.<br>
> E370 Westgate Building<br>
> College of Information Sciences and Technology<br>
> The Pennsylvania State University<br>
> <br>
<br>
<br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature">-Michael Wayne Goodman</div></div>