Skip to content

add more sorting options in longturtle serializer #2880

Open
@VladimirAlexiev

Description

@VladimirAlexiev

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

  • add prefixes for all used props.
    • I don't use nsN: prefixes
    • I first consult https://prefix.cc
    • (*) If not, I make a reasonable prefix myself.
  • sort prefixes alphabetically
    • (*) but the own ontology prefix first
    • I also align namespaces on <
  • sort turtle blocks (subjects) alphabetically by prefixed name, not full URL
    • It's better to first sort by kind (see sections below)
    • but the ontology node first
    • (*) also author records and any other subsidiary nodes describing the ontology
    • (*) any external terms last
  • I also add comments to delineate the sections. They come in this order:
    • ### Ontology
    • ### Classes
    • ### Properties
    • ### Individuals
    • ### External Terms
      • You could also sort them by kind, but then do you make 3 sections per external ontology?
      • Since there are usually few external terms, better to keep them all in one section.

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 #2881 are implemented, I'll switch from jena riot to rdflib.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions