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.15k stars 555 forks source link

add more sorting options in longturtle serializer #2880

Open VladimirAlexiev opened 1 month ago

VladimirAlexiev commented 1 month ago

@nicholascar, @fititnt, maybe @gwhigs The main purpose of longturtle is to facilitate better diffs. Sorting has a lot to do with stability (diff minimization), so I'll share more experience.

Call me weird, but I prefer to read reasonably small ontologies (up to 50 classes, 100 props) in turtle rather than in an ontology editor. So each time I get some ontology, I convert it to turtle (using riot --formatted=ttl) and then :

Note: the (*) items are harder to implement, so they are optional.

Related links:

AFAIK, rdflib and TQ are the only software that care about the aesthetics of turtle output. If this and https://github.com/RDFLib/rdflib/issues/2881 are implemented, I'll switch from jena riot to rdflib.

fititnt commented 1 month ago

Just saw the mention, will comment quickly (I have no strong opinion to remember at the moment).

While I don't know (maybe not even exist single person) who come with the nice formatting, its really, really fantastic both the formatting (at least compared with how was done 15~20 years ago) and... have some way to force programs (even if optional) to try hard keep a a consistent output, because it helps when doing diffs.

One of my use cases for this was run same scripts that get data (for example, Wikidata, also converting tables from open data sources) and generating some formats (and RDF is one of then) and if anything minimal changes, is possible also explore the diffs.

About the specific suggestions of @VladimirAlexiev, I have no opinion on very specific details (but I do agree with the general idea). Also, its not merely aesthetics , but helps with diffs.

(And I also would be okay if any of the programs I'm using at some point would change the defaults)

VladimirAlexiev commented 2 days ago

atextor/turtle-formatter is a Jena/Java tool specifically for this purpose