ontolearn.base.owl.hierarchy

Classes representing hierarchy in OWL.

Module Contents

Classes

AbstractHierarchy

Representation of an abstract hierarchy which can be used for classes or properties.

ClassHierarchy

Representation of a class hierarchy.

ObjectPropertyHierarchy

Representation of an objet property hierarchy.

DatatypePropertyHierarchy

Representation of a data property hierarchy.

class ontolearn.base.owl.hierarchy.AbstractHierarchy(factory: Type[_S], hierarchy_down: Iterable[Tuple[_S, Iterable[_S]]])[source]
class ontolearn.base.owl.hierarchy.AbstractHierarchy(factory: Type[_S], reasoner: owlapy.owl_reasoner.OWLReasoner)

Bases: Generic[_S]

Representation of an abstract hierarchy which can be used for classes or properties.

Parameters:
  • hierarchy_down – A downwards hierarchy given as a mapping of Entities to sub-entities.

  • reasoner – Alternatively, a reasoner whose root_ontology is queried for entities.

__slots__ = ('_Type', '_ent_set', '_parents_map', '_parents_map_trans', '_children_map',...
abstract classmethod get_top_entity() _S[source]

The most general entity in this hierarchy, which contains all the entities.

abstract classmethod get_bottom_entity() _S[source]

The most specific entity in this hierarchy, which contains none of the entities.

static restrict(hierarchy: _U, *, remove: Iterable[_S] = None, allow: Iterable[_S] = None) _U[source]

Restrict a given hierarchy to a set of allowed/removed entities.

Parameters:
  • hierarchy – An existing Entity hierarchy to restrict.

  • remove – Set of entities which should be ignored.

  • allow – Set of entities which should be used.

Returns:

The restricted hierarchy.

restrict_and_copy(*, remove: Iterable[_S] = None, allow: Iterable[_S] = None) _U[source]

Restrict this hierarchy.

See restrict for more info.

parents(entity: _S, direct: bool = True) Iterable[_S][source]

Parents of an entity.

Parameters:
  • entity – Entity for which to query parent entities.

  • direct – False to return transitive parents.

Returns:

Super-entities.

is_parent_of(a: _S, b: _S) bool[source]

if A is a parent of B.

Note

A is always a parent of A.

is_child_of(a: _S, b: _S) bool[source]

If A is a child of B.

Note

A is always a child of A.

children(entity: _S, direct: bool = True) Iterable[_S][source]

Children of an entity.

Parameters:
  • entity – Entity for which to query child entities.

  • direct – False to return transitive children.

Returns:

Sub-entities.

siblings(entity: _S) Iterable[_S][source]
items() Iterable[_S][source]
roots(of: _S | None = None) Iterable[_S][source]
leaves(of: _S | None = None) Iterable[_S][source]
__contains__(item: _S) bool[source]
__len__()[source]
class ontolearn.base.owl.hierarchy.ClassHierarchy(hierarchy_down: Iterable[Tuple[owlapy.class_expression.OWLClass, Iterable[owlapy.class_expression.OWLClass]]])[source]
class ontolearn.base.owl.hierarchy.ClassHierarchy(reasoner: owlapy.owl_reasoner.OWLReasoner)

Bases: AbstractHierarchy[owlapy.class_expression.OWLClass]

Representation of a class hierarchy.

Parameters:
  • hierarchy_down – A downwards hierarchy given as a mapping of Class to sub-classes.

  • reasoner – Alternatively, a reasoner whose root_ontology is queried for classes and sub-classes.

classmethod get_top_entity() owlapy.class_expression.OWLClass[source]

The most general entity in this hierarchy, which contains all the entities.

classmethod get_bottom_entity() owlapy.class_expression.OWLClass[source]

The most specific entity in this hierarchy, which contains none of the entities.

sub_classes(entity: owlapy.class_expression.OWLClass, direct: bool = True) Iterable[owlapy.class_expression.OWLClass][source]
super_classes(entity: owlapy.class_expression.OWLClass, direct: bool = True) Iterable[owlapy.class_expression.OWLClass][source]
is_subclass_of(subclass: owlapy.class_expression.OWLClass, superclass: owlapy.class_expression.OWLClass) bool[source]
class ontolearn.base.owl.hierarchy.ObjectPropertyHierarchy(hierarchy_down: Iterable[Tuple[owlapy.owl_property.OWLObjectProperty, Iterable[owlapy.owl_property.OWLObjectProperty]]])[source]
class ontolearn.base.owl.hierarchy.ObjectPropertyHierarchy(reasoner: owlapy.owl_reasoner.OWLReasoner)

Bases: AbstractHierarchy[owlapy.owl_property.OWLObjectProperty]

Representation of an objet property hierarchy.

classmethod get_top_entity() owlapy.owl_property.OWLObjectProperty[source]

The most general entity in this hierarchy, which contains all the entities.

classmethod get_bottom_entity() owlapy.owl_property.OWLObjectProperty[source]

The most specific entity in this hierarchy, which contains none of the entities.

sub_object_properties(entity: owlapy.owl_property.OWLObjectProperty, direct: bool = True) Iterable[owlapy.owl_property.OWLObjectProperty][source]
super_object_properties(entity: owlapy.owl_property.OWLObjectProperty, direct: bool = True) Iterable[owlapy.owl_property.OWLObjectProperty][source]
more_general_roles(role: owlapy.owl_property.OWLObjectProperty, direct: bool = True) Iterable[owlapy.owl_property.OWLObjectProperty][source]
more_special_roles(role: owlapy.owl_property.OWLObjectProperty, direct: bool = True) Iterable[owlapy.owl_property.OWLObjectProperty][source]
is_sub_property_of(sub_property: owlapy.owl_property.OWLObjectProperty, super_property: owlapy.owl_property.OWLObjectProperty) bool[source]
most_general_roles() Iterable[owlapy.owl_property.OWLObjectProperty][source]
most_special_roles() Iterable[owlapy.owl_property.OWLObjectProperty][source]
class ontolearn.base.owl.hierarchy.DatatypePropertyHierarchy(hierarchy_down: Iterable[Tuple[owlapy.owl_property.OWLDataProperty, Iterable[owlapy.owl_property.OWLDataProperty]]])[source]
class ontolearn.base.owl.hierarchy.DatatypePropertyHierarchy(reasoner: owlapy.owl_reasoner.OWLReasoner)

Bases: AbstractHierarchy[owlapy.owl_property.OWLDataProperty]

Representation of a data property hierarchy.

classmethod get_top_entity() owlapy.owl_property.OWLDataProperty[source]

The most general entity in this hierarchy, which contains all the entities.

classmethod get_bottom_entity() owlapy.owl_property.OWLDataProperty[source]

The most specific entity in this hierarchy, which contains none of the entities.

sub_data_properties(entity: owlapy.owl_property.OWLDataProperty, direct: bool = True)[source]
super_data_properties(entity: owlapy.owl_property.OWLDataProperty, direct: bool = True)[source]
more_general_roles(role: owlapy.owl_property.OWLDataProperty, direct: bool = True) Iterable[owlapy.owl_property.OWLDataProperty][source]
more_special_roles(role: owlapy.owl_property.OWLDataProperty, direct: bool = True) Iterable[owlapy.owl_property.OWLDataProperty][source]
is_sub_property_of(sub_property: owlapy.owl_property.OWLDataProperty, super_property: owlapy.owl_property.OWLDataProperty) bool[source]
most_general_roles() Iterable[owlapy.owl_property.OWLDataProperty][source]
most_special_roles() Iterable[owlapy.owl_property.OWLDataProperty][source]