Skip to content

Commit

Permalink
fix(owlgen): no triple needed for imported terms
Browse files Browse the repository at this point in the history
It is not possible to inherit from terms from external vocabularies (for
example, you cannot write "is_a: schema:Person"), since those terms are
not available in the schema.

One way to make them available in the schema is explicitly declaring
them like this (for the above example with "schema:Person":
    Person:
      class_uri: schema:Person
but it creates an unexpected class declaration in the OWL ontology
saying that "schema:Person is an exactMatch of schema:Person".

This patch gets rid of all those superfluous declarations.

Signed-off-by: Silvano Cirujano Cuesta <silvano.cirujano-cuesta@siemens.com>
  • Loading branch information
Silvanoc committed May 11, 2023
1 parent f06d45b commit e985a19
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions linkml/generators/owlgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ def visit_class(self, cls: ClassDefinition) -> bool:
# representation, consult https://www.w3.org/TR/owl2-mapping-to-rdf/
cls_uri = self._class_uri(cls.name)
self.add_mappings(cls)
for mapping in cls.mappings:
if cls_uri == self.namespaces.uri_for(mapping):
logging.info(f"not adding class {cls.name} since it's only 'importing' an external term")
return
self.add_metadata(cls, cls_uri)
# add declaration
self.graph.add((cls_uri, RDF.type, OWL.Class))
Expand Down Expand Up @@ -380,6 +384,10 @@ def visit_slot(self, slot_name: str, slot: SlotDefinition) -> None:
return

slot_uri = self._prop_uri(slot.name)
for mapping in slot.mappings:
if slot_uri == self.namespaces.uri_for(mapping):
logging.info(f"not adding slot {slot.name} since it's only 'importing' an external term")
return
# logging.error(f'SLOT_URI={slot_uri}')

# Slots may be modeled as Object or Datatype Properties
Expand Down

0 comments on commit e985a19

Please sign in to comment.