From ec016394862e2a830fa21e4fe4e797d234d6a851 Mon Sep 17 00:00:00 2001 From: Michael Wayne Goodman Date: Mon, 11 Dec 2023 09:13:44 -0800 Subject: [PATCH] Fix #373 capture single-quoted predicates > 1 char --- CHANGELOG.md | 2 ++ delphin/codecs/simplemrs.py | 2 +- tests/codecs/simplemrs_test.py | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19c9022..98e82b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ * Stop using Python's undocumented parse_template re function ([#378]) * Resolved newline and encoding issues for running tests on Windows ([#379]) +* Capture legacy single-quoted predicates longer than 1 character ([#373]) ## [v1.8.1] @@ -1620,6 +1621,7 @@ information about changes, except for [#360]: https://github.com/delph-in/pydelphin/issues/360 [#364]: https://github.com/delph-in/pydelphin/issues/364 [#367]: https://github.com/delph-in/pydelphin/issues/367 +[#373]: https://github.com/delph-in/pydelphin/issues/373 [#374]: https://github.com/delph-in/pydelphin/issues/374 [#375]: https://github.com/delph-in/pydelphin/issues/375 [#376]: https://github.com/delph-in/pydelphin/issues/376 diff --git a/delphin/codecs/simplemrs.py b/delphin/codecs/simplemrs.py index 0501270..3020aaf 100644 --- a/delphin/codecs/simplemrs.py +++ b/delphin/codecs/simplemrs.py @@ -140,7 +140,7 @@ def encode(m, properties=True, lnk=True, indent=False): r'|@\d+' r'|\d+(?: +\d+)*)>', 'LNK:a lnk value'), (r'"([^"\\]*(?:\\.[^"\\]*)*)"', 'DQSTRING:a string'), - (r"'([^ \n:<>\[\]])", 'SQSYMBOL:a quoted symbol'), + (r"'([^ \n:<>\[\]]+)", 'SQSYMBOL:a quoted symbol'), (r'_[^\s_]+' # lemma r'_[nvajrscpqxud]' # pos r'(?:_(?:[^\s_<]|<(?![-0-9:#@ ]*>\s))+)?' # optional sense diff --git a/tests/codecs/simplemrs_test.py b/tests/codecs/simplemrs_test.py index ac1e28b..3866398 100644 --- a/tests/codecs/simplemrs_test.py +++ b/tests/codecs/simplemrs_test.py @@ -80,3 +80,9 @@ def test_escapes_issue_367(): m2 = simplemrs.decode(s) assert m == m2 assert m.surface == m2.surface + + +def test_legacy_single_quote_predicates_issue_373(): + # https://github.com/delph-in/pydelphin/issues/373 + m = simplemrs.decode("[ RELS: < [ 'single+quoted LBL: h0 ] > ]") + assert m.rels[0].predicate == "single+quoted"