diff --git a/CHANGELOG.md b/CHANGELOG.md index 0606cf2..cd2021f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ * `Sense.relation_map()` method ([#216]) * `Synset.relation_map()` method ([#167], [#216]) +## Fixed + +* Enumerate repeated entry, sense, synset IDs for validation ([#228]) + ## [v0.10.1] @@ -706,3 +710,4 @@ abandoned, but this is an entirely new codebase. [#215]: https://github.com/goodmami/wn/issues/215 [#216]: https://github.com/goodmami/wn/issues/216 [#221]: https://github.com/goodmami/wn/issues/221 +[#228]: https://github.com/goodmami/wn/issues/228 diff --git a/tests/data/E101-0.xml b/tests/data/E101-0.xml new file mode 100644 index 0000000..0ab813c --- /dev/null +++ b/tests/data/E101-0.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/data/E101-1.xml b/tests/data/E101-1.xml new file mode 100644 index 0000000..d8c925c --- /dev/null +++ b/tests/data/E101-1.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/tests/data/E101-2.xml b/tests/data/E101-2.xml new file mode 100644 index 0000000..38a1822 --- /dev/null +++ b/tests/data/E101-2.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + diff --git a/tests/data/E101-3.xml b/tests/data/E101-3.xml new file mode 100644 index 0000000..7c5b232 --- /dev/null +++ b/tests/data/E101-3.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + diff --git a/tests/validate_test.py b/tests/validate_test.py new file mode 100644 index 0000000..76935db --- /dev/null +++ b/tests/validate_test.py @@ -0,0 +1,18 @@ +from pathlib import Path + +from wn import lmf +from wn.validate import validate + + +def _assert_invalid(select: str, path: Path) -> None: + lex = lmf.load(path, progress_handler=None)["lexicons"][0] + report = validate(lex, select=[select], progress_handler=None) + print(report) + assert len(report[select]["items"]) > 0 + + +def test_E101(datadir): + _assert_invalid("E101", datadir / "E101-0.xml") + _assert_invalid("E101", datadir / "E101-1.xml") + _assert_invalid("E101", datadir / "E101-2.xml") + _assert_invalid("E101", datadir / "E101-3.xml") diff --git a/wn/validate.py b/wn/validate.py index c5d387c..9e9dd4b 100644 --- a/wn/validate.py +++ b/wn/validate.py @@ -57,9 +57,9 @@ def _non_unique_id(lex: lmf.Lexicon, ids: _Ids) -> _Result: [lex['id']], (f['id'] for e in _entries(lex) for f in _forms(e) if f.get('id')), (sb['id'] for sb in lex.get('frames', []) if sb.get('id')), - ids['entry'], - ids['sense'], - ids['synset'], + ids['entry'].elements(), + ids['sense'].elements(), + ids['synset'].elements(), ))