Ontology: Add custom_properties (e.g. for OWL import) - #146
jochenchrist wants to merge 10 commits into
Conversation
Importing an ontology from an external format such as OWL/RDF loses any data that the core OSI spec does not model (IRIs, rdfs:label, owl:equivalentClass, annotations, provenance, ...), because every ontology object is locked down with additionalProperties: false. Add an open `custom_properties` object to the ontology root, concepts, relationships, and roles. Keys are free-form and values may be any JSON, so tools can preserve foreign data and round-trip it. CURIEs like `owl:equivalentClass` are recommended for semantic-web sources. The rest of each object keeps additionalProperties: false, so custom_properties is the single, explicit escape hatch. Includes a FOAF/OWL import example and documents the field in the spec. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
RDF labels and comments are usually language-tagged and the previous example used a plain string, which is lossy. Recommend the readable `prefix:local@lang` key convention for language-tagged literals (the `@` cannot appear in a CURIE local name, so it parses unambiguously), and point at the JSON-LD value-object form for the multi-value and typed literal cases that the flat form cannot express. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
kurtStirewalt
left a comment
There was a problem hiding this comment.
This is a nice addition!
jbonofre
left a comment
There was a problem hiding this comment.
Overall good, I just wonder if we should use custom_properties or custom_extensions.
@jochenchrist @kurtStirewalt thoughts?
Resolve conflicts with the flattened concept declarations: custom_properties now sits on the flattened OntologyComponent instead of the removed Concept def, and the docs example uses the flattened concept syntax.
|
@jbonofre @kurtStirewalt Option AStructured Example: Consequences:
Option BSame with Consequences:
What do you think? |
|
Option A would be my preference. On language tags why not use the RDF convention of delimiting the string, e.g. |
| ```yaml | ||
| custom_properties: | ||
| rdfs:label@en: "Person" | ||
| rdfs:label@fr: "Personne" |
There was a problem hiding this comment.
This will be very messy to parse, in my opinion. Why not:
rdfs:label:
en: "Person"
fr: "Personne"
This would not require mixing in the language tag into the property IRI, which is some new invented syntax. The syntax I wrote above is already used in LinkML-Scala.
custom_properties is an opaque, free-form object. Remove the recommended CURIE key naming and the rdfs:label@lang / JSON-LD value-object guidance from the schema description, docs, and example so the spec makes no assumptions about the structure of its contents.
…ples Concepts and relationships already have a first-class uri field, so the custom_properties examples no longer duplicate it under an iri key.
… import The docs now show custom_properties on a ContributionMargin value type (abbreviation, formula, unit, better_when, owner) so the free-form nature of the keys is clear. The FOAF example declares a prefixes map and keys its properties by the source predicate's QName, noted as the importer's own convention rather than a spec requirement.
Summary
Importing an ontology from an external format such as OWL/RDF currently loses any data that the core OSI spec does not model (labels, equivalence axioms, annotations, provenance, and so on) because every ontology object is locked down with
additionalProperties: false. There is no place to put it, so a round-trip (OWL → OSI → OWL) is lossy.This PR adds an open
custom_propertiesobject to the ontology root, concepts, relationships, and roles. Keys are free-form and values may be any JSON, so importers can preserve foreign data and round-trip it. The spec does not interpret or constrain the structure ofcustom_properties. The rest of each object keepsadditionalProperties: false, socustom_propertiesis the single, explicit escape hatch rather than letting arbitrary keys leak in anywhere.An OWL importer would instead key properties by the source predicate (
rdfs:label,owl:equivalentClass); seeexamples/foaf_owl_import.yaml. The choice of keys belongs to the tool that writes them, not the spec.Design notes
The core spec (logical model) already has a
custom_extensions: [{vendor_name, data}]mechanism wheredatais a stringified JSON blob. I deliberately did not reuse that here:vendor_nameblob is an awkward fit.If maintainers would prefer to unify on one extensibility mechanism spec-wide, I'm happy to switch this to the
custom_extensionsshape instead. Flagging the choice explicitly.Changes
ontology/ontology.json: add a reusableCustomProperties$defand reference it from the root,Concept,Relationship, andRole.ontology/ontology.md: add the field to the four schema tables, a new "Custom properties" section with a metrics example, and a version-history note.examples/foaf_owl_import.yaml: a small FOAF/OWL import example exercisingcustom_propertiesat the root, concept, and relationship levels, with aprefixesmap and QName keys.Validation
ontology/ontology.jsonis well-formed JSON.examples/flights.yamlboth validate against the updated schema (Draft 2020-12).custom_properties.