Generating DMRS from MRS

What is the best way to generate DMRS representations from MRS, and what is the best way to get visualizations for them? This page (Demo (delphin-viz)) creates them for English, but I’m looking to generate them from a Thai grammar I’m working on!

Hi,

PyDelphin will create them and make latex or json, this json can then be used by e.g., the demo page.

1 Like

I’m looking at PyDelphin and I can see that there is a delphin.dmrs.from_mrs method that will convert an mrs to a dmrs - but I’m still unsure of what format the input MRS would need to be in - is there a way to give it the MRS generated directly from the LKB?

Hi @vipashab,

The delphin.dmrs.from_mrs() function operates on objects of the internal delphin.mrs.MRS class. If you have parsed and stored MRS objects from ACE or the LKB, most likely you have stored what is called the “SimpleMRS” format (here is some general information about MRS formats). So you would first need to decode the serialized form of the MRS, then do the conversion.

>>> from delphin.codecs import simplemrs
>>> from delphin import dmrs
>>> m = simplemrs.decode("""[ LTOP: h0 INDEX: e2 [ e SF: prop TENSE: past MOOD: indicative PROG: - PERF: - ] RELS: < [ _the_q<0:3> LBL: h4 ARG0: x3 [ x PERS: 3 NUM: sg IND: + ] RSTR: h5 BODY: h6 ]  [ _dog_n_1<4:7> LBL: h7 ARG0: x3 ]  [ _bark_v_1<8:15> LBL: h1 ARG0: e2 ARG1: x3 ] > HCONS: < h0 qeq h1 h5 qeq h7 > ICONS: < > ]""")
>>> d = dmrs.from_mrs(m)
>>> d
<DMRS object (_the_q _dog_n_1 _bark_v_1) at 140419860195232>

This object is usable in Python. If you want to serialize it, you’ll need a DMRS codec:

>>> from delphin.codecs import simpledmrs
>>> print(simpledmrs.encode(d, indent=2))
dmrs {
  [top=10002 index=10002]
  10000 [_the_q<0:3>];
  10001 [_dog_n_1<4:7> x PERS=3 NUM=sg IND=+];
  10002 [_bark_v_1<8:15> e SF=prop TENSE=past MOOD=indicative PROG=- PERF=-];
  10000:RSTR/H -> 10001;
  10002:ARG1/NEQ -> 10001;
}