oxigraph / oxigraph

SPARQL graph database
Apache License 2.0
1.01k stars 67 forks source link

Isomorphism support in pyoxigraph #821

Closed DylanVanAssche closed 5 months ago

DylanVanAssche commented 6 months ago

Is your feature request related to a problem? Please describe.

I'm part of the W3C Community Group on Knowledge Graph Construction. We are having a Challenge at ESWC 2024 conference where participants with their RML engine can compete in compliance with the new RML modules. One of them is RML-Star for generating RDF-Star. We provide a tool to run the test-cases of each module and compare the output with what is expected. However, I got stuck with RML-Star with RDFLib which led me to search for an alternative here.

Describe the solution you'd like

Pyoxigraph can read 2 graphs, but does not expose the option to make them isomorph before checking their equality. Exposing isomorphism to pyoxigraph would be amazing because oxigraph can already do it with Graph and Dataset.

Describe alternatives you've considered

RDFLib can read 2 graphs and compare them if they are equal by making both isomorph and then check if they are equal. RDFLib does not do RDF-Star, pyoxigraph does.

Additional context

RDFLib's compare module: https://rdflib.readthedocs.io/en/stable/_modules/rdflib/compare.html

Tpt commented 5 months ago

Done in pyoxigraph 0.4.0-alpha.5: https://pyoxigraph.readthedocs.io/en/latest/model.html#pyoxigraph.Dataset.canonicalize

DylanVanAssche commented 5 months ago

Thanks @Tpt !

If I understand it correctly, I can now do the same as with RDFLib to compare 2 graphs:

Tpt commented 5 months ago

@DylanVanAssche Yes, except you need to use the Dataset class and not the Store class

DylanVanAssche commented 5 months ago

@Tpt Thanks!

Dataset does not have a load statement to read from a file. Or do I look at it in the wrong way?

Tpt commented 5 months ago

@DylanVanAssche Indeed. But you can do Dataset(load(path"my_file.txt"))

DylanVanAssche commented 5 months ago

Ah amazing! Thanks!