Compositional semantics for the ERG with PyDelphin

,

I am attempting to generate text from MRSes that are composed on the fly based on input from a graph that represents a particular entity.

I am starting small and just trying to generate a noun by itself (e.g. phone), then I want to try adding explicit quantifiers after that.

I input the string phone into the ERG and am looking into the resulting MRS and am trying to reverse engineer a generator.

Here is the MRS I got:

[ 
  LTOP: h0 
  INDEX: e2 [ e SF: prop-or-ques ] 
  RELS: < 
    [ unknown<0:5> LBL: h1 ARG0: e2 ARG: x4 [ x PERS: 3 NUM: sg IND: + ] ]  
    [ udef_q<0:5> LBL: h5 ARG0: x4 RSTR: h6 BODY: h7 ]  
    [ _phone_n_1<0:5> LBL: h8 ARG0: x4 ] > 
  HCONS: < h0 qeq h1 h6 qeq h8 > 
  ICONS: < > 
]

I have created the following pieces for the generator so far:

  • noun(predicate_label) – takes a predicate_label and returns an MRS that has only the EP for that noun in the RELS list.
  • bare_np(daughter_mrs) – creates an MRS with the udef_q EP in the RELS list then calls scopal_compose on that MRS and the daughter_mrs (described below)

COMPOSITION RULES

  • intersective_compose(head_mrs, non_head_mrs) – creates a new MRS which has the combined RELS and HCONS lists of the daughters. I am not sure how to handle assigning the LTOP, which is part of why I made this post.
  • scopal_compose(scope_mrs, non_scope_mrs) – creates a new MRS which has the combined RELS and HCONS lists of the daughters, plus the additional necessary scoping handle constraint and sets LTOP to be that of the scoping daughter.
  • root(daughter_mrs) – adds the unknown event predicate plus the required handle constraint that relates the GTOP to the LTOP of the daughter.

QUESTIONS

  1. In the introduction to MRS paper, it states that for intersective combination “the local tops of the daughters are equated with each other and with the local top of the phrase’s MRS” … I am unsure how to do this in PyDelphin as it seems I would just be choosing one of the two daughters’ LTOPs to be the new LTOP, but that doesn’t seem to ensure that the two daughters now have equated LTOPs.
  2. I haven’t yet considered how to incorporate the PERS, NUM, IND, and SF information, and don’t really have a good idea of where I would do that. If I build an MRS without that will the generator “figure it out” in a way?
  3. Not really a question, but if there’s anything that seems obviously incorrect about my approach please let me know! I’m new to using the ERG and might be making incorrect guesses about how things work.

Hi Liz,

That remark is about composing an MRS within a grammar. “Daughters” refers to constituents in a phrase structure tree, which isn’t what you have to hand. I’d start by just leaving the LTOP unlinked to anything and see if that causes any problems.

Yes, leaving these underspecified should just lead to extra generated strings. Start there and then add constraints as you need :slight_smile:

I think the problem I’m facing with what you’re suggesting is that it makes it difficult for me to insert the new qeq constraint if I don’t have an LTOP handle to grab onto.

So when I’m doing the scopal_composition I want to essentially do the following:

rstr_lbl = [get RSTR label from ARGS list of the scopal EP]
scoped_lbl = [LTOP of the thing that the scopal EP has scope over]
new_hcons = delphin.mrs.HCons(rstr_lbl, 'qeq', scoped_lbl)

I don’t know of any way to generally grab such a handle without it being associated to the LTOP. If it was just one predicate then it would be easy to get the label of just that predicate, but I want to account for cases when I’m scoping over an MRS with a whole bag of EPs. But again I’m new to this so I could be missing something obvious.

What you’re missing is English syntax :wink: More seriously: you could use the LTOP as you go to point to the LTOP. So, when it’s just the _n_rel, then the LTOP is its LBL. And when you add a relative clause to the _n_rel, the LTOP should still point to the _n_rel’s LBL. (The ERG doesn’t do any scopal modifiers of nouns, so in fact, you could always just grab the ‘head’ noun’s LBL… you’ll really only need to worry about this for things inside the relative clauses when you get there.)

Hm… still not quite sure I understand. Particularly “The ERG doesn’t do any scopal modifiers of nouns.”

Maybe scopal modifier isn’t the term I’m looking for, but in the MRS I provided above, it the udef_q predicate ends up having a qeq relationship with the phone_n_1 predicate. And my concern is what if I actually had something more complex than just “phone”?

I might be answering my own question now that I’m typing it. I think I was picturing syntax trees… I was imagining “well what if I had ‘mobile phone’ … I would want the LTOP of that whole ‘phrase’ not just ‘phone’” … but as you pointed out I’m not dealing with syntax, so this idea of a “phrase” is irrelevant and I guess it just needs to scope over “phone” and then the adjective will be connected to “phone” via its own argument… maybe. It still feels odd to me that I don’t need to ensure that udef_q is scoping over “the whole thing” though…

So the quantifier isn’t a modifier and yes it needs the noun’s LBL. But I think your question boils down to asking: which noun in this bag is the ‘main one’.

Maybe scopal modifier isn’t the term I’m looking for, but in the MRS I provided above, it the udef_q predicate ends up having a qeq relationship with the phone_n_1 predicate. And my concern is what if I actually had something more complex than just “phone”?

To be precise, a qeq relationship holds between a handle and a label, instead of predicates, hence, between the RSTR handle of udef_q and the label of _phone_n_1. In case of mobile phone, you should see these in the MRS:

image

_mobile_a_1 and _phone_n_1 shares the same label h8, which is in a qeq relationship with the RSTR handle of udef_q h6, which is what you are imagining:

I was imagining “well what if I had ‘mobile phone’ … I would want the LTOP of that whole ‘phrase’ not just ‘phone’”

Correct me if I am wrong!

1 Like

You have to think about two parallel structures. The predicate-argument structure and the scope tree - using the @guyemerson terminology from https://arxiv.org/pdf/2006.03002.pdf (Fig 2).

1 Like

An implementation of MRS-based semantic composition is something I’m very interested in, but unfortunately don’t have much time to help out with. But I’d be very happy to review a PR to add such functionality into PyDelphin.

As an option, you might consider composing things in DMRS (see the discussion on DMRS algebra from a few years back: StanfordAlgebraAdditions · delph-in/docs Wiki · GitHub), then to convert these to MRS. DMRS doesn’t involve variables, so you just specify the relationships on the edges. E.g., adding a RSTR/H link between a quantifier and a noun will effect the labels and qeqs you need when converting to MRS.

If you stay in MRS-land, there are some functions that might help, such as delphin.mrs.is_well_formed() and related checks, and maybe delphin.scope.conjoin().