Skip to content

Commit

Permalink
Better deal with bad MRSs in conversion
Browse files Browse the repository at this point in the history
There are two separate issues that are fixed here:

* When multiple non-quantifier EPs share an ARG0 it caused problems
  with mapping variables to quantifiers

* When the INDEX was not used by any EP it caused a lookup error

Fixes #267
  • Loading branch information
goodmami committed Jan 14, 2020
1 parent 96b5cb1 commit 7588d51
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ these changes are prefixed with "**BREAKING**"
* `delphin.codecs.edspenman` now properly reads predicate names
* `delphin.codecs.edspenman` and `delphin.codecs.dmrspenman` now wrap
`PenmanError` in `PyDelphinException` ([#266][])
* `delphin.mrs.MRS.quantification_pairs()` detects and ignores when
quantifier(s) are shared by multiple EPs ([#267][])
* `delphin.dmrs.from_mrs()` detects when an INDEX is specified but is
not the intrinsic argument of any EP ([#267][])

### Changed

Expand Down Expand Up @@ -1248,4 +1252,5 @@ information about changes, except for
[#263]: https://github.com/delph-in/pydelphin/issues/263
[#264]: https://github.com/delph-in/pydelphin/issues/264
[#266]: https://github.com/delph-in/pydelphin/issues/266
[#267]: https://github.com/delph-in/pydelphin/issues/267
[#268]: https://github.com/delph-in/pydelphin/issues/268
6 changes: 5 additions & 1 deletion delphin/dmrs/_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ def from_mrs(m, representative_priority=None):
for ep in m.rels if not ep.is_quantifier()}

top = _mrs_get_top(m.top, hcmap, reps, id_to_nid)
index = iv_to_nid[m.index] if m.index else None
# some bad MRSs have an INDEX that isn't the ARG0 of any EP, so
# make sure it exists first
index = None
if m.index and m.index in iv_to_nid:
index = iv_to_nid[m.index]
nodes = _mrs_to_nodes(m, id_to_nid)
links = _mrs_to_links(m, hcmap, reps, iv_to_nid, id_to_nid)

Expand Down
4 changes: 3 additions & 1 deletion delphin/mrs/_mrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,9 @@ def quantification_pairs(self):
pairs.append((ep, qmap.get(ep.iv)))
# then unpaired quantifiers, if any
for _, q in pairs:
if q is not None:
# some bad MRSs have multiple EPs share an ARG0; avoid the
# KeyError by checking if they are still in qmap
if q is not None and q.iv in qmap:
del qmap[q.iv]
for q in qmap.values():
pairs.append((None, q))
Expand Down

0 comments on commit 7588d51

Please sign in to comment.