-
Notifications
You must be signed in to change notification settings - Fork 555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: two issues with the N3 serializer #1858
fix: two issues with the N3 serializer #1858
Conversation
d57d967
to
e8202e0
Compare
8068241
to
05692e7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The N3 serializer does not consider that the predicate of a triple can also be a graph.
It can? Eww. Excellent catch.
It is a bit odd yes, noticed it when I ran roundtrip for this test: :cwm_syntax_neg-formula-predicate.n3
a test:TestN3PositiveSyntax ;
mf:action <cwm_syntax/neg-formula-predicate.n3> ;
mf:name "neg-formula-predicate.n3" ;
rdfs:comment "A predicate cannot be a formula, I hope ; yes it can!";
rdft:approval rdft:Approved . File here:
And the only reason it failed round tripping is because the namespace was not being serialized for the quad in the middle, with this fix the reconstituted graph looks like this: DEBUG test.test_roundtrip:test_roundtrip.py:237 source = /home/iwana/sw/d/github.com/iafork/rdflib.cleanish/test/data/suites/w3c/n3/N3Tests/cwm_syntax/neg-formula-predicate.n3, serailized =
@prefix ns1: <file:///home/iwana/sw/d/github.com/iafork/rdflib.cleanish/test/data/suites/w3c/n3/N3Tests/cwm_syntax/neg-formula-predicate.n3#> .
ns1:a{
ns1:b ns1:c ns1:d .
} ns1:e . Without it: DEBUG test.test_roundtrip:test_roundtrip.py:237 source = /home/iwana/sw/d/github.com/iafork/rdflib.cleanish/test/data/suites/w3c/n3/N3Tests/cwm_syntax/neg-formula-predicate.n3, serailized =
<file:///home/iwana/sw/d/github.com/iafork/rdflib.cleanish/test/data/suites/w3c/n3/N3Tests/cwm_syntax/neg-formula-predicate.n3#a>{
ns1:b ns1:c ns1:d .
} ns1:e . Had to double check the grammar to believe it also: https://github.com/w3c/N3/blob/master/grammar/n3.ebnf
|
The comment suggests it's perhaps not intended to be that way but is an entailment of the EBNF expression.
|
315bbe5
to
5b2c826
Compare
@eikeon not sure if you are familiar with the N3 serializer but if you are please have a look, I'm fairly confident about this change but maybe I'm missing something here also. |
@blackwint3r this ideally needs one more review, please consider doing a review if you have time. |
5b2c826
to
277af70
Compare
277af70
to
50b1746
Compare
resolving conflicts |
50b1746
to
1f0641f
Compare
This patch fixes two issues with the N3 serializer: - The N3 serializer incorrectly considered a subject as already serialized if it has been serialized inside a quoted graph. - The N3 serializer does not consider that the predicate of a triple can also be a graph. Other changes included in this patch: - Changed `test.testutils.GraphHelper` to support nested/quoted graphs. - Moved the tests from `test/test_n3_formula.py` into `test/test_serializers/test_serializer_n3.py`. - Include positive syntax tests from the N3 test suite that is smaller than 1024KB and that is not using new N3 syntax into round trip tests. This is mainly to check that there is no regressions after the changes made. Fixes: - RDFLib#1807 - RDFLib#1701
1f0641f
to
f38979e
Compare
@RDFLib/core I will merge this by 2022-05-17 if there is no further feedback. |
Merging this with only one approval as it is a fairly simple fix and includes extensive testing. |
Summary of changes
This patch fixes two issues with the N3 serializer:
serialized if it has been serialized inside a quoted graph.
a triple can also be a graph.
Other changes included in this patch:
test.testutils.GraphHelper
to support nested/quoted graphs.test/test_n3_formula.py
intotest/test_serializers/test_serializer_n3.py
.than 1024KB and that is not using new N3 syntax into round trip tests.
This is mainly to check that there is no regressions after the changes
made.
Fixes:
Checklist
the same change.
so maintainers can fix minor issues and keep your PR up to date.