Skip to content

Commit

Permalink
Fix #334: SimpleDMRS no longer requires top/index
Browse files Browse the repository at this point in the history
  • Loading branch information
goodmami committed Sep 12, 2021
1 parent 95d66e8 commit ce1d935
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@

* REPP mask (`=`) operator and full masking support ([#331])

### Fixed

* SimpleDMRS no longer requires `index` or `top` to be specified when
decoding ([#334])

### Changed

* REPP no longer requires iterative group calls to appear after the
group definitions ([#308])


## [v1.5.1]

**Release date: 2021-01-05**
Expand Down Expand Up @@ -1508,3 +1514,4 @@ information about changes, except for
[#323]: https://github.com/delph-in/pydelphin/issues/323
[#324]: https://github.com/delph-in/pydelphin/issues/324
[#331]: https://github.com/delph-in/pydelphin/issues/331
[#334]: https://github.com/delph-in/pydelphin/issues/334
4 changes: 2 additions & 2 deletions delphin/codecs/simpledmrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ def _decode_dmrs(lexer):
links.append(_decode_link(nodeid, lexer))
lexer.expect_type(RBRACE)

return DMRS(top=int(top),
index=int(index),
return DMRS(top=int(top) if top is not None else None,
index=int(index) if index is not None else None,
nodes=nodes,
links=links,
lnk=lnk,
Expand Down
20 changes: 20 additions & 0 deletions tests/codecs/simpledmrs_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def test_encode(it_rains_heavily_dmrs, abrams_barked_dmrs):
' 30:ARG1/NEQ -> 20;'
' }')


def test_decode(it_rains_heavily_dmrs):
d = simpledmrs.decode(
'dmrs {'
Expand Down Expand Up @@ -129,3 +130,22 @@ def test_loads(it_rains_heavily_dmrs):
assert ds[1].index == it_rains_heavily_dmrs.index
assert ds[1].nodes == it_rains_heavily_dmrs.nodes
assert ds[1].links == it_rains_heavily_dmrs.links


def test_decode_no_index_issue_334():
# https://github.com/delph-in/pydelphin/issues/334
d = simpledmrs.decode(
'dmrs {'
' [top=10]'
' 10 [_rain_v_1<3:9> e TENSE=past];'
'}'
)
assert d.index is None

d = simpledmrs.decode(
'dmrs {'
' 10 [_rain_v_1<3:9> e TENSE=past];'
'}'
)
assert d.top is None
assert d.index is None

0 comments on commit ce1d935

Please sign in to comment.