Skip to content

Commit

Permalink
Fixed hierarchy init when using SyncReasoner #125
Browse files Browse the repository at this point in the history
  • Loading branch information
alkidbaci committed Feb 2, 2025
1 parent 7972d4f commit 7b22f64
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions owlapy/owl_hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,10 @@ def get_bottom_entity(cls) -> OWLClass:
return OWLNothing

def _hierarchy_down_generator(self, reasoner: AbstractOWLReasoner) -> Iterable[Tuple[OWLClass, Iterable[OWLClass]]]:
clss = set(reasoner.get_root_ontology().classes_in_signature())
clss.add(OWLNothing)
yield from ((_, reasoner.sub_classes(_, direct=True))
for _ in reasoner.get_root_ontology().classes_in_signature())
for _ in clss)

def sub_classes(self, entity: OWLClass, direct: bool = True) -> Iterable[OWLClass]:
yield from self.children(entity, direct)
Expand Down Expand Up @@ -298,10 +300,12 @@ def get_bottom_entity(cls) -> OWLObjectProperty:

def _hierarchy_down_generator(self, reasoner: AbstractOWLReasoner) \
-> Iterable[Tuple[OWLObjectProperty, Iterable[OWLObjectProperty]]]:
o_props = set(reasoner.get_root_ontology().object_properties_in_signature())
o_props.add(OWLBottomObjectProperty)
return ((_, map(lambda _: cast(OWLObjectProperty, _),
filter(lambda _: isinstance(_, OWLObjectProperty),
reasoner.sub_object_properties(_, direct=True))))
for _ in reasoner.get_root_ontology().object_properties_in_signature())
for _ in o_props)

def sub_object_properties(self, entity: OWLObjectProperty, direct: bool = True) -> Iterable[OWLObjectProperty]:
yield from self.children(entity, direct)
Expand Down Expand Up @@ -346,8 +350,10 @@ def get_bottom_entity(cls) -> OWLDataProperty:

def _hierarchy_down_generator(self, reasoner: AbstractOWLReasoner) \
-> Iterable[Tuple[OWLDataProperty, Iterable[OWLDataProperty]]]:
d_props = set(reasoner.get_root_ontology().data_properties_in_signature())
d_props.add(OWLBottomDataProperty)
return ((_, reasoner.sub_data_properties(_, direct=True))
for _ in reasoner.get_root_ontology().data_properties_in_signature())
for _ in d_props)

def sub_data_properties(self, entity: OWLDataProperty, direct: bool = True):
yield from self.children(entity, direct)
Expand Down

0 comments on commit 7b22f64

Please sign in to comment.