Skip to content
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

Closed
wants to merge 12 commits into from

Conversation

nikokaoja
Copy link
Contributor

No description provided.

Copy link
Contributor

@Tpt Tpt left a 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)

<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> .
Copy link
Contributor

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

tests/test_parser.py Outdated Show resolved Hide resolved
<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> .
Copy link
Contributor

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.

@@ -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
Copy link
Contributor

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.

Suggested change
graph_identifier = to_ox(sink.identifier) if format not in ("ox-nq", "ox-nquads") else None
graph_identifier = to_ox(sink.identifier)

@Tpt
Copy link
Contributor

Tpt commented Oct 17, 2024

@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?

@nikokaoja
Copy link
Contributor Author

@Tpt great ! Will do update of this PR by end of this week.

@Tpt
Copy link
Contributor

Tpt commented Oct 22, 2024

@nikokaoja Amazing! I already implemented serializers in #51 and found a few ways to simplify the code a bit.

@nikokaoja
Copy link
Contributor Author

Screenshot 2024-10-26 at 09 55 44

@Tpt still same issue when rebasing main, default_context is empy

@Tpt
Copy link
Contributor

Tpt commented Oct 26, 2024

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

@nikokaoja
Copy link
Contributor Author

nikokaoja commented Oct 26, 2024

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, .default_context is empty. I guess it is something with config on pyoxigraph side?

@Tpt
Copy link
Contributor

Tpt commented Oct 27, 2024

@Tpt still the same issue, .default_context is empty. I guess it is something with config on pyoxigraph side?

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.

@nikokaoja
Copy link
Contributor Author

@Tpt still the same issue, .default_context is empty. I guess it is something with config on pyoxigraph side?

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

@Tpt
Copy link
Contributor

Tpt commented Oct 27, 2024

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?

@nikokaoja
Copy link
Contributor Author

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.

@nikokaoja
Copy link
Contributor Author

This PR has been abandoned

@nikokaoja nikokaoja closed this Oct 27, 2024
@nikokaoja nikokaoja deleted the feat-parser-nquads branch October 27, 2024 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants