RDFLib / rdflib

RDFLib is a Python library for working with RDF, a simple yet powerful language for representing information.
https://rdflib.readthedocs.org
BSD 3-Clause "New" or "Revised" License
2.14k stars 555 forks source link

Document RDFLib and pyld usage patterns #2823

Open edmondchuc opened 1 month ago

edmondchuc commented 1 month ago

We are collecting common use cases and patterns with working with JSON-LD in RDFLib and pyld and plan to add them to the RDFLib documentation.

The below details copied from this comment: https://github.com/RDFLib/rdflib/issues/2308#issuecomment-2227524343

The pyld + RDFLib things I normally do:

Getting RDF into a framed JSON-LD

The above is the same for compaction and expansion by using the relevant function in the pyld processor.

Parsing JSON-LD with pyld and loading into an RDFLib graph

ajnelson-nist commented 1 month ago

A usage[^1] pattern I have is similar to your first heading, @edmondchuc . I have workflows that generate Git-tracked example data - most often in Turtle and/or JSON-LD. The steps I take are:

  1. Serialize a graph as JSON-LD.
  2. Use PyLD for compaction.

One example is in these Makefile lines, which call a Python wrapper to pyld.jsonld.compact here.

I wrote that logic a while before rdflib-jsonld was integrated into rdflib, and never got around to looking. Is there access to a compaction function in rdflib somewhere that obviates this usage pattern?

[^1]: Participation by NIST in the creation of the documentation of mentioned software is not intended to imply a recommendation or endorsement by the National Institute of Standards and Technology, nor is it intended to imply that any specific software is necessarily the best available for the purpose.