Editing ontology

Dear all,

so we finally migrated to knora v9.0.0.

Now a project wants to make some changes on their ontology.

What procedure do you recommend?

Dumping the ontology graph from graphdb doesn’t give a human readable result.

And the API calls like https://api.dasch.swiss/v2/ontologies/allentities/{{ontology_encoded_iri}} don’t give an file we can feed back in knora (with knora-api).

What is the clever trick that I can’t figure out?

Thanks and best regards to all and best recovery to the concerned ones,
Loïc.

Here is the documentation on updating ontologies via Knora API v2:

https://docs.knora.org/paradox/03-apis/api-v2/ontology-information.html#ontology-updates

But the Knora API won’t let you change classes or properties in an ontology if they’re already used in data. If you just want to add a few small things, maintaining backwards compatibility with existing data, you could load the project’s ontology without its data, make the changes via the API, then load the data.

The Knora-ui team is working on an ontology editor GUI.

Another option would be to recreate the ontology from scratch using knora-py.

Dumping the ontology graph from graphdb doesn’t give a human readable result.

You can reformat RDF using any RDF processing library. rdflib produces nicely formatted Turtle output.

Isn’t it possible to add new resources and new properties to an existing ontology using V2? I think so, since knora-py builds the ontology piece by piece.

I will have a look at it – eventually I can add some knora-py tools to extend an existing ontology. It is obvious that an existing proprerty that is used cannot be changed…

Eventually unused properties may be deleted…

Isn’t it possible to add new resources and new properties to an existing ontology using V2?

Yes. But there are restrictions on changing existing classes and properties:

  • An entity (i.e. a class or property) cannot be referred to until it
    has been created.
  • An entity cannot be modified or deleted if it is used in data,
    except for changes to its rdfs:label or rdfs:comment.
  • An entity cannot be modified if another entity refers to it, with
    one exception: a knora-api:subjectType or knora-api:objectType
    that refers to a class will not prevent the class’s cardinalities
    from being modified.

This is documented here:

https://docs.knora.org/paradox/03-apis/api-v2/ontology-information.html#ontology-updates

These rules are simple and conservative. We could make them more sophisticated and less restrictive.

Very reasonable rules I think!

On the present case we have to deal with, the dump as ttl and reformat with rdflib is what makes sense as the project members are used to edit the ontology.

Thanks a lot Ben and Lukas :slight_smile: