Skip to content

Commit

Permalink
fixes #46
Browse files Browse the repository at this point in the history
  • Loading branch information
cmungall committed May 29, 2024
1 parent 0159462 commit 2f3e320
Show file tree
Hide file tree
Showing 7 changed files with 344 additions and 346 deletions.
1 change: 1 addition & 0 deletions docs/tutorial/pizza01-toppings-model.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ classes:
slot_uri: rdfs:label
conforms_to:
name: conforms_to
range: string
annotations:
owl.fstring: AnnotationAssertion( dcterms:conformsTo {id} pizza:{V} )
slot_uri: dcterms:conformsTo
Expand Down
18 changes: 14 additions & 4 deletions linkml_owl/dumpers/owl_dumper.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
SubObjectPropertyOf, TransitiveObjectProperty, SymmetricObjectProperty, AsymmetricObjectProperty, \
ReflexiveObjectProperty, IrreflexiveObjectProperty, Annotation, ObjectMinCardinality, ObjectHasValue, \
NamedIndividual, DataSomeValuesFrom, DataHasValue, DataAllValuesFrom, AnnotationProperty, DataProperty, Datatype, \
DisjointClasses, DisjointUnion
DisjointClasses, DisjointUnion, DataPropertyAssertion

from linkml_runtime.dumpers.dumper_root import Dumper
from linkml_runtime.utils.yamlutils import YAMLRoot
Expand Down Expand Up @@ -210,9 +210,15 @@ def transform(self, element: YAMLRoot, schema: SchemaDefinition, is_element_an_o
if element is None:
return None
try:
# translate Enum
meaning = element.meaning
return self._get_IRI_str(meaning)
# translate Enum
if is_element_an_object or True:
if not meaning:
enum_uri = schema.default_prefix + ":" + type(element).__name__
meaning = enum_uri + "#" + str(element).replace(" ", "+")
return self._get_IRI_str(meaning)
else:
return str(element)
except AttributeError:
pass
if not self._instance_of_linkml_class(element):
Expand Down Expand Up @@ -324,6 +330,8 @@ def transform(self, element: YAMLRoot, schema: SchemaDefinition, is_element_an_o
slot_interps = self._get_slot_interpretations(slot, linkml_class_name)
logging.debug(f'OWL interpretations for {k}={slot_interps}')
is_object_ref = slot.range in self.schema.classes
#if "ObjectPropertyAssertion" in slot_interps or "ObjectProperty" in slot_interps:
# is_object_ref = True
# normalize input_vals to a list, then recursively transform
if isinstance(v, list):
input_vals = v
Expand Down Expand Up @@ -390,7 +398,7 @@ def transform(self, element: YAMLRoot, schema: SchemaDefinition, is_element_an_o
# eai.add_operands((0, SubClassOf.__name__, ObjectUnionOf.__name__), parents, axiom_annotations)
axiom_type = None
# TODO: make this more generic / less repetitive
axiom_types = [SubClassOf, SubObjectPropertyOf, ClassAssertion, ObjectPropertyAssertion, EquivalentClasses, InverseObjectProperties,ObjectPropertyDomain, ObjectPropertyRange, AnnotationAssertion]
axiom_types = [SubClassOf, SubObjectPropertyOf, ClassAssertion, ObjectPropertyAssertion, DataPropertyAssertion, EquivalentClasses, InverseObjectProperties,ObjectPropertyDomain, ObjectPropertyRange, AnnotationAssertion]
for candidate_axiom_type in axiom_types:
if candidate_axiom_type.__name__ in slot_interps:
axiom_type = candidate_axiom_type
Expand Down Expand Up @@ -445,6 +453,8 @@ def transform(self, element: YAMLRoot, schema: SchemaDefinition, is_element_an_o
axiom = ClassAssertion(parent, subj)
elif axiom_type == ObjectPropertyAssertion:
axiom = ObjectPropertyAssertion(slot_uri, subj, parent)
elif axiom_type == DataPropertyAssertion:
axiom = DataPropertyAssertion(slot_uri, subj, parent)
elif axiom_type == InverseObjectProperties:
axiom = InverseObjectProperties(subj, parent)
elif axiom_type == ObjectPropertyDomain:
Expand Down
Loading

0 comments on commit 2f3e320

Please sign in to comment.