-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add support for parsing N-Quads #47
Conversation
Exposes Oxigraph parsers (oxigraph#45)
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.
Thank you! Might be great to have some test coverage around the default graph (default graph behaviors of rdflib are weird)
tests/data/test.nq
Outdated
<http://example.org/stuff/1.0/document> <http://xmlns.com/foaf/0.1/creator> <http://example.org/stuff/1.0/creator> <http://example.com/graph1> . | ||
<http://example.org/stuff/1.0/creator> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> <http://example.com/graph1> . | ||
<http://example.org/stuff/1.0/creator> <http://xmlns.com/foaf/0.1/name> "John Doe" <http://example.com/graph1> . | ||
<http://example.org/stuff/1.0/creator> <http://xmlns.com/foaf/0.1/mbox> <mailto:[email protected]> <http://example.com/graph1> . |
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.
Would be great to have a few quads in the default graph to check that they are properly loaded into the default graph
<http://example.org/stuff/1.0/document> <http://xmlns.com/foaf/0.1/title> "Example Document" <http://example.com/graph2> . | ||
<http://example.org/stuff/1.0/creator> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> <http://example.com/graph3> . | ||
<http://example.org/stuff/1.0/creator> <http://xmlns.com/foaf/0.1/name> "John Doe" <urn:x-rdflib:default> . | ||
<http://example.org/stuff/1.0/creator> <http://xmlns.com/foaf/0.1/mbox> <mailto:[email protected]> <urn:x-rdflib:default> . |
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.
It would be great to test with the actual NQuads default graph like <http://example.org/stuff/1.0/creator> <http://xmlns.com/foaf/0.1/mbox> <mailto:[email protected]> .
.
I believe proper support for the default graph would require moving the quads in a named graph (likely urn:x-rdflib:default
). Sadly pyoxigraph 0.3.x does not support that but pyoxigraph 0.4 alphas does.
oxrdflib/parser.py
Outdated
@@ -47,6 +47,7 @@ def parse( | |||
|
|||
else: | |||
base_iri = sink.absolutize(source.getPublicId() or source.getSystemId() or "") | |||
graph_identifier = to_ox(sink.identifier) if format not in ("ox-nq", "ox-nquads") else None |
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.
We should map the default graph for dataset formats too.
graph_identifier = to_ox(sink.identifier) if format not in ("ox-nq", "ox-nquads") else None | |
graph_identifier = to_ox(sink.identifier) |
@nikokaoja I have merged pyoxigraph 0.4 support in the main branch. Do you want to rebase your MR? If not, may I build on top of it? |
@Tpt great ! Will do update of this PR by end of this week. |
@nikokaoja Amazing! I already implemented serializers in #51 and found a few ways to simplify the code a bit. |
@Tpt still same issue when rebasing main, |
Thank you for pushing this! I wrote an untested draft that should properly insert in the correct graph and supports other store: #53 Feel free to reuse the code. I also found a nice way to automate tests for serializers, it might be handy for the parsers too |
@Tpt still the same issue, |
This is weird, I have updated #53 with some tests that are passing. I also fixed the loading into not-Oxigraph stores that seems now to work. Edit: tests are passing with Python 3.12 but not with Python 3.8. It sounds like something sensitive to the Python version. |
I am running it with Python 3.11 and have the above reported behaviour. So it seems it works only with 3.12 |
I understood the error, it's because of changes in rdflib 7.1 that fixes the support of default graph. I am afraid it will be hard to make things work with older versions. I have gated the tests in my PR on v7.1 and also fixed a small bug in OxigraphStore in #54 that was making iteration on the dataset fail. If it's fine with you, I can maybe just merge my MR. WDYT? |
Sure, np , remove my PR then. |
This PR has been abandoned |
No description provided.