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 initial implementation of RDF Patch parser. #2863

Merged
merged 17 commits into from
Aug 26, 2024

Conversation

recalcitrantsupplant
Copy link
Contributor

@recalcitrantsupplant recalcitrantsupplant commented Jul 30, 2024

Summary of changes

Introduces support for parsing RDF Patch files, aligned to the specification here: https://afs.github.io/rdf-delta/rdf-patch.html

Supports:

  • Adding and Deleting triples and quads from a Dataset.
  • Adding and Deleting prefixes from a Dataset.
  • blank node ID preservation from input documents. That is, blank nodes are NOT document scoped when parsing patches.
    blank nodes can be specified either using the format:
    • _:identifier
    • <_:identifier>
      both will be parsed as blank nodes and their identifier from the document they are parsed from preserved.

Known limitations:

  • No support yet for Patch logs (a series of Patch files)

Checklist

  • Checked that there aren't other open pull requests for
    the same change.
  • Checked that all tests and type checking passes.
  • If the change adds new features or changes the RDFLib public API:
    • Created an issue to discuss the change and get in-principle agreement. Discussed with a number of maintainers
      TODO:
    • Considered adding an example in ./examples.
    • Considered adding additional documentation.

rdflib/plugins/parsers/patch.py Outdated Show resolved Hide resolved
rdflib/plugins/parsers/patch.py Show resolved Hide resolved
rdflib/plugins/parsers/patch.py Outdated Show resolved Hide resolved
rdflib/plugins/parsers/patch.py Outdated Show resolved Hide resolved
@coveralls
Copy link

coveralls commented Aug 5, 2024

Coverage Status

coverage: 90.617% (+0.01%) from 90.605%
when pulling 7262244 on recalcitrantsupplant:david/rdf-patch-parser
into cb5d058 on RDFLib:main.

@ashleysommer
Copy link
Contributor

@edmondchuc Merging is blocked on your pending review. Can you please re-review and approve to so we can merge it.

examples/parse_patch.py Outdated Show resolved Hide resolved
)
# type error: Incompatible types in assignment (expression has type "ConjunctiveGraph", base class "W3CNTriplesParser" defined the type as "Union[DummySink, NTGraphSink]")
self.sink: Dataset = Dataset(store=sink.store)
self.skolemize = skolemize
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And can remove these now after the changes in 0e75969?

Probably doesn't affect anything since it defaults to False in the super class.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I just mirrored the other parsers here. Could there be use cases where someone wants to skolemize when parsing?

@ashleysommer ashleysommer merged commit aa9d103 into RDFLib:main Aug 26, 2024
22 checks passed
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.

5 participants