diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ca1094..9ea3005 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ * `penman.interface` is removed from the public API but remains temporarily for backward compatibility ([#78]) +### Fixed + +* `parse_triples()` now prepends a colon to roles ([#80]) + ### Changed * Make `parse()`, `format()`, `interpret()`, and `configure()` @@ -697,3 +701,4 @@ First release with very basic functionality. [#76]: https://github.com/goodmami/penman/issues/76 [#77]: https://github.com/goodmami/penman/issues/77 [#78]: https://github.com/goodmami/penman/issues/78 +[#80]: https://github.com/goodmami/penman/issues/80 diff --git a/penman/_parse.py b/penman/_parse.py index c54b291..9e64fbf 100644 --- a/penman/_parse.py +++ b/penman/_parse.py @@ -155,6 +155,8 @@ def _parse_triples(tokens: TokenIterator) -> List[BasicTriple]: role = tokens.expect('SYMBOL').text if strip_caret and role.startswith('^'): role = role[1:] + if not role.startswith(':'): + role = ':' + role tokens.expect('LPAREN') # SYMBOL may contain commas, so handle it here. If there # is no space between the comma and the next SYMBOL, they diff --git a/tests/test_codec.py b/tests/test_codec.py index 576ab23..40c79be 100644 --- a/tests/test_codec.py +++ b/tests/test_codec.py @@ -18,7 +18,7 @@ def test_parse(self): assert codec.parse('(a / alpha)') == ('a', [('/', 'alpha')]) def test_parse_triples(self): - assert codec.parse_triples('role(a, b)') == [('a', 'role', 'b')] + assert codec.parse_triples('role(a, b)') == [('a', ':role', 'b')] def test_format(self): assert codec.format(('a', [('/', 'alpha')])) == '(a / alpha)'