:py:mod:`ontolearn.base` ======================== .. py:module:: ontolearn.base .. autoapi-nested-parse:: Implementations of owlapy abstract classes based on owlready2. Subpackages ----------- .. toctree:: :titlesonly: :maxdepth: 3 ext/index.rst owl/index.rst Submodules ---------- .. toctree:: :titlesonly: :maxdepth: 1 axioms/index.rst complex_ce_instances/index.rst fast_instance_checker/index.rst plus/index.rst utils/index.rst Package Contents ---------------- Classes ~~~~~~~ .. autoapisummary:: ontolearn.base.OWLOntologyManager_Owlready2 ontolearn.base.OWLReasoner_Owlready2 ontolearn.base.OWLOntology_Owlready2 ontolearn.base.BaseReasoner_Owlready2 ontolearn.base.OWLReasoner_Owlready2_ComplexCEInstances ontolearn.base.OWLReasoner_FastInstanceChecker .. py:class:: OWLOntologyManager_Owlready2(world_store=None) Bases: :py:obj:`owlapy.owl_ontology_manager.OWLOntologyManager` An OWLOntologyManager manages a set of ontologies. It is the main point for creating, loading and accessing ontologies. .. py:attribute:: __slots__ :value: '_world' .. py:method:: create_ontology(iri: owlapy.iri.IRI) -> OWLOntology_Owlready2 Creates a new (empty) ontology that that has the specified ontology IRI (and no version IRI). :param iri: The IRI of the ontology to be created. :returns: The newly created ontology, or if an ontology with the specified IRI already exists then this existing ontology will be returned. .. py:method:: load_ontology(iri: owlapy.iri.IRI) -> OWLOntology_Owlready2 Loads an ontology that is assumed to have the specified ontology IRI as its IRI or version IRI. The ontology IRI will be mapped to an ontology document IRI. :param iri: The IRI that identifies the ontology. It is expected that the ontology will also have this IRI (although the OWL API should tolerate situations where this is not the case). :returns: The OWLOntology representation of the ontology that was loaded. .. py:method:: apply_change(change: owlapy.owl_ontology_manager.OWLOntologyChange) A convenience method that applies just one change to an ontology. When this method is used through an OWLOntologyManager implementation, the instance used should be the one that the ontology returns through the get_owl_ontology_manager() call. :param change: The change to be applied. :raises ChangeApplied.UNSUCCESSFULLY: if the change was not applied successfully. .. py:method:: add_axiom(ontology: owlapy.owl_ontology.OWLOntology, axiom: owlapy.owl_axiom.OWLAxiom) A convenience method that adds a single axiom to an ontology. :param ontology: The ontology to add the axiom to. :param axiom: The axiom to be added. .. py:method:: remove_axiom(ontology: owlapy.owl_ontology.OWLOntology, axiom: owlapy.owl_axiom.OWLAxiom) A convenience method that removes a single axiom from an ontology. :param ontology: The ontology to remove the axiom from. :param axiom: The axiom to be removed. .. py:method:: save_ontology(ontology: owlapy.owl_ontology.OWLOntology, document_iri: owlapy.iri.IRI) Saves the specified ontology, using the specified document IRI to determine where/how the ontology should be saved. :param ontology: The ontology to be saved. :param document_iri: The document IRI where the ontology should be saved to. .. py:method:: save_world() Saves the actual state of the quadstore in the SQLite3 file. .. py:class:: OWLReasoner_Owlready2(ontology: OWLOntology_Owlready2, isolate: bool = False) Bases: :py:obj:`ontolearn.base.ext.OWLReasonerEx` Extra convenience methods for OWL Reasoners (Not part of OWLAPI) .. py:attribute:: __slots__ :value: ('_ontology', '_world') .. py:method:: update_isolated_ontology(axioms_to_add: List[owlapy.owl_axiom.OWLAxiom] = None, axioms_to_remove: List[owlapy.owl_axiom.OWLAxiom] = None) Add or remove axioms to the isolated ontology that the reasoner is using. :param axioms_to_add: Axioms to add to the isolated ontology. :type axioms_to_add: List[OWLAxiom] :param axioms_to_remove: Axioms to remove from the isolated ontology. :type axioms_to_remove: List[OWLAxiom] .. py:method:: data_property_domains(pe: owlapy.owl_property.OWLDataProperty, direct: bool = False) -> Iterable[owlapy.class_expression.OWLClassExpression] Gets the class expressions that are the direct or indirect domains of this property with respect to the imports closure of the root ontology. :param pe: The property expression whose domains are to be retrieved. :param direct: Specifies if the direct domains should be retrieved (True), or if all domains should be retrieved (False). :returns: Let N = equivalent_classes(DataSomeValuesFrom(pe rdfs:Literal)). If direct is True: then if N is not empty then the return value is N, else the return value is the result of super_classes(DataSomeValuesFrom(pe rdfs:Literal), true). If direct is False: then the result of super_classes(DataSomeValuesFrom(pe rdfs:Literal), false) together with N if N is non-empty. (Note, rdfs:Literal is the top datatype). .. py:method:: object_property_domains(pe: owlapy.owl_property.OWLObjectProperty, direct: bool = False) -> Iterable[owlapy.class_expression.OWLClassExpression] Gets the class expressions that are the direct or indirect domains of this property with respect to the imports closure of the root ontology. :param pe: The property expression whose domains are to be retrieved. :param direct: Specifies if the direct domains should be retrieved (True), or if all domains should be retrieved (False). :returns: Let N = equivalent_classes(ObjectSomeValuesFrom(pe owl:Thing)). If direct is True: then if N is not empty then the return value is N, else the return value is the result of super_classes(ObjectSomeValuesFrom(pe owl:Thing), true). If direct is False: then the result of super_classes(ObjectSomeValuesFrom(pe owl:Thing), false) together with N if N is non-empty. .. py:method:: object_property_ranges(pe: owlapy.owl_property.OWLObjectProperty, direct: bool = False) -> Iterable[owlapy.class_expression.OWLClassExpression] Gets the class expressions that are the direct or indirect ranges of this property with respect to the imports closure of the root ontology. :param pe: The property expression whose ranges are to be retrieved. :param direct: Specifies if the direct ranges should be retrieved (True), or if all ranges should be retrieved (False). :returns: Let N = equivalent_classes(ObjectSomeValuesFrom(ObjectInverseOf(pe) owl:Thing)). If direct is True: then if N is not empty then the return value is N, else the return value is the result of super_classes(ObjectSomeValuesFrom(ObjectInverseOf(pe) owl:Thing), true). If direct is False: then the result of super_classes(ObjectSomeValuesFrom(ObjectInverseOf(pe) owl:Thing), false) together with N if N is non-empty. .. py:method:: equivalent_classes(ce: owlapy.class_expression.OWLClassExpression, only_named: bool = True) -> Iterable[owlapy.class_expression.OWLClassExpression] Gets the class expressions that are equivalent to the specified class expression with respect to the set of reasoner axioms. :param ce: The class expression whose equivalent classes are to be retrieved. :param only_named: Whether to only retrieve named equivalent classes or also complex class expressions. :returns: All class expressions C where the root ontology imports closure entails EquivalentClasses(ce C). If ce is not a class name (i.e. it is an anonymous class expression) and there are no such classes C then there will be no result. If ce is unsatisfiable with respect to the set of reasoner axioms then owl:Nothing, i.e. the bottom node, will be returned. .. py:method:: disjoint_classes(ce: owlapy.class_expression.OWLClassExpression, only_named: bool = True) -> Iterable[owlapy.class_expression.OWLClassExpression] Gets the class expressions that are disjoint with specified class expression with respect to the set of reasoner axioms. :param ce: The class expression whose disjoint classes are to be retrieved. :param only_named: Whether to only retrieve named disjoint classes or also complex class expressions. :returns: All class expressions D where the set of reasoner axioms entails EquivalentClasses(D ObjectComplementOf(ce)) or StrictSubClassOf(D ObjectComplementOf(ce)). .. py:method:: different_individuals(ind: owlapy.owl_individual.OWLNamedIndividual) -> Iterable[owlapy.owl_individual.OWLNamedIndividual] Gets the individuals that are different from the specified individual with respect to the set of reasoner axioms. :param ind: The individual whose different individuals are to be retrieved. :returns: All individuals x where the set of reasoner axioms entails DifferentIndividuals(ind x). .. py:method:: same_individuals(ind: owlapy.owl_individual.OWLNamedIndividual) -> Iterable[owlapy.owl_individual.OWLNamedIndividual] Gets the individuals that are the same as the specified individual with respect to the set of reasoner axioms. :param ind: The individual whose same individuals are to be retrieved. :returns: All individuals x where the root ontology imports closure entails SameIndividual(ind x). .. py:method:: data_property_values(ind: owlapy.owl_individual.OWLNamedIndividual, pe: owlapy.owl_property.OWLDataProperty, direct: bool = True) -> Iterable[owlapy.owl_literal.OWLLiteral] Gets the data property values for the specified individual and data property expression. :param ind: The individual that is the subject of the data property values. :param pe: The data property expression whose values are to be retrieved for the specified individual. :param direct: Specifies if the direct values should be retrieved (True), or if all values should be retrieved (False), so that sub properties are taken into account. :returns: A set of OWLLiterals containing literals such that for each literal l in the set, the set of reasoner axioms entails DataPropertyAssertion(pe ind l). .. py:method:: all_data_property_values(pe: owlapy.owl_property.OWLDataProperty, direct: bool = True) -> Iterable[owlapy.owl_literal.OWLLiteral] Gets all values for the given data property expression that appear in the knowledge base. :param pe: The data property expression whose values are to be retrieved :param direct: Specifies if only the direct values of the data property pe should be retrieved (True), or if the values of sub properties of pe should be taken into account (False). :returns: A set of OWLLiterals containing literals such that for each literal l in the set, the set of reasoner axioms entails DataPropertyAssertion(pe ind l) for any ind. .. py:method:: object_property_values(ind: owlapy.owl_individual.OWLNamedIndividual, pe: owlapy.owl_property.OWLObjectPropertyExpression, direct: bool = False) -> Iterable[owlapy.owl_individual.OWLNamedIndividual] Gets the object property values for the specified individual and object property expression. :param ind: The individual that is the subject of the object property values. :param pe: The object property expression whose values are to be retrieved for the specified individual. :param direct: Specifies if the direct values should be retrieved (True), or if all values should be retrieved (False), so that sub properties are taken into account. :returns: The named individuals such that for each individual j, the set of reasoner axioms entails ObjectPropertyAssertion(pe ind j). .. py:method:: flush() -> None Flushes any changes stored in the buffer, which causes the reasoner to take into consideration the changes the current root ontology specified by the changes. .. py:method:: instances(ce: owlapy.class_expression.OWLClassExpression, direct: bool = False) -> Iterable[owlapy.owl_individual.OWLNamedIndividual] Gets the individuals which are instances of the specified class expression. :param ce: The class expression whose instances are to be retrieved. :param direct: Specifies if the direct instances should be retrieved (True), or if all instances should be retrieved (False). :returns: If direct is True, each named individual j where the set of reasoner axioms entails DirectClassAssertion(ce, j). If direct is False, each named individual j where the set of reasoner axioms entails ClassAssertion(ce, j). If ce is unsatisfiable with respect to the set of reasoner axioms then nothing returned. .. py:method:: sub_classes(ce: owlapy.class_expression.OWLClassExpression, direct: bool = False, only_named: bool = True) -> Iterable[owlapy.class_expression.OWLClassExpression] Gets the set of named classes that are the strict (potentially direct) subclasses of the specified class expression with respect to the reasoner axioms. :param ce: The class expression whose strict (direct) subclasses are to be retrieved. :param direct: Specifies if the direct subclasses should be retrieved (True) or if the all subclasses (descendant) classes should be retrieved (False). :param only_named: Whether to only retrieve named sub-classes or also complex class expressions. :returns: If direct is True, each class C where reasoner axioms entails DirectSubClassOf(C, ce). If direct is False, each class C where reasoner axioms entails StrictSubClassOf(C, ce). If ce is equivalent to owl:Nothing then nothing will be returned. .. py:method:: super_classes(ce: owlapy.class_expression.OWLClassExpression, direct: bool = False, only_named: bool = True) -> Iterable[owlapy.class_expression.OWLClassExpression] Gets the stream of named classes that are the strict (potentially direct) super classes of the specified class expression with respect to the imports closure of the root ontology. :param ce: The class expression whose strict (direct) super classes are to be retrieved. :param direct: Specifies if the direct super classes should be retrieved (True) or if the all super classes (ancestors) classes should be retrieved (False). :param only_named: Whether to only retrieve named super classes or also complex class expressions. :returns: If direct is True, each class C where the set of reasoner axioms entails DirectSubClassOf(ce, C). If direct is False, each class C where set of reasoner axioms entails StrictSubClassOf(ce, C). If ce is equivalent to owl:Thing then nothing will be returned. .. py:method:: equivalent_object_properties(op: owlapy.owl_property.OWLObjectPropertyExpression) -> Iterable[owlapy.owl_property.OWLObjectPropertyExpression] Gets the simplified object properties that are equivalent to the specified object property with respect to the set of reasoner axioms. :param op: The object property whose equivalent object properties are to be retrieved. :returns: All simplified object properties e where the root ontology imports closure entails EquivalentObjectProperties(op e). If op is unsatisfiable with respect to the set of reasoner axioms then owl:bottomDataProperty will be returned. .. py:method:: equivalent_data_properties(dp: owlapy.owl_property.OWLDataProperty) -> Iterable[owlapy.owl_property.OWLDataProperty] Gets the data properties that are equivalent to the specified data property with respect to the set of reasoner axioms. :param dp: The data property whose equivalent data properties are to be retrieved. :returns: All data properties e where the root ontology imports closure entails EquivalentDataProperties(dp e). If dp is unsatisfiable with respect to the set of reasoner axioms then owl:bottomDataProperty will be returned. .. py:method:: disjoint_object_properties(op: owlapy.owl_property.OWLObjectPropertyExpression) -> Iterable[owlapy.owl_property.OWLObjectPropertyExpression] Gets the simplified object properties that are disjoint with the specified object property with respect to the set of reasoner axioms. :param op: The object property whose disjoint object properties are to be retrieved. :returns: All simplified object properties e where the root ontology imports closure entails EquivalentObjectProperties(e ObjectPropertyComplementOf(op)) or StrictSubObjectPropertyOf(e ObjectPropertyComplementOf(op)). .. py:method:: disjoint_data_properties(dp: owlapy.owl_property.OWLDataProperty) -> Iterable[owlapy.owl_property.OWLDataProperty] Gets the data properties that are disjoint with the specified data property with respect to the set of reasoner axioms. :param dp: The data property whose disjoint data properties are to be retrieved. :returns: All data properties e where the root ontology imports closure entails EquivalentDataProperties(e DataPropertyComplementOf(dp)) or StrictSubDataPropertyOf(e DataPropertyComplementOf(dp)). .. py:method:: super_data_properties(dp: owlapy.owl_property.OWLDataProperty, direct: bool = False) -> Iterable[owlapy.owl_property.OWLDataProperty] Gets the stream of data properties that are the strict (potentially direct) super properties of the specified data property with respect to the imports closure of the root ontology. :param dp: The data property whose super properties are to be retrieved. :type dp: OWLDataProperty :param direct: Specifies if the direct super properties should be retrieved (True) or if the all super properties (ancestors) should be retrieved (False). :type direct: bool :returns: Iterable of super properties. .. py:method:: sub_data_properties(dp: owlapy.owl_property.OWLDataProperty, direct: bool = False) -> Iterable[owlapy.owl_property.OWLDataProperty] Gets the set of named data properties that are the strict (potentially direct) subproperties of the specified data property expression with respect to the imports closure of the root ontology. :param dp: The data property whose strict (direct) subproperties are to be retrieved. :param direct: Specifies if the direct subproperties should be retrieved (True) or if the all subproperties (descendants) should be retrieved (False). :returns: If direct is True, each property P where the set of reasoner axioms entails DirectSubDataPropertyOf(P, pe). If direct is False, each property P where the set of reasoner axioms entails StrictSubDataPropertyOf(P, pe). If pe is equivalent to owl:bottomDataProperty then nothing will be returned. .. py:method:: super_object_properties(op: owlapy.owl_property.OWLObjectPropertyExpression, direct: bool = False) -> Iterable[owlapy.owl_property.OWLObjectPropertyExpression] Gets the stream of object properties that are the strict (potentially direct) super properties of the specified object property with respect to the imports closure of the root ontology. :param op: The object property expression whose super properties are to be retrieved. :type op: OWLObjectPropertyExpression :param direct: Specifies if the direct super properties should be retrieved (True) or if the all super properties (ancestors) should be retrieved (False). :type direct: bool :returns: Iterable of super properties. .. py:method:: sub_object_properties(op: owlapy.owl_property.OWLObjectPropertyExpression, direct: bool = False) -> Iterable[owlapy.owl_property.OWLObjectPropertyExpression] Gets the stream of simplified object property expressions that are the strict (potentially direct) subproperties of the specified object property expression with respect to the imports closure of the root ontology. :param op: The object property expression whose strict (direct) subproperties are to be retrieved. :param direct: Specifies if the direct subproperties should be retrieved (True) or if the all subproperties (descendants) should be retrieved (False). :returns: If direct is True, simplified object property expressions, such that for each simplified object property expression, P, the set of reasoner axioms entails DirectSubObjectPropertyOf(P, pe). If direct is False, simplified object property expressions, such that for each simplified object property expression, P, the set of reasoner axioms entails StrictSubObjectPropertyOf(P, pe). If pe is equivalent to owl:bottomObjectProperty then nothing will be returned. .. py:method:: types(ind: owlapy.owl_individual.OWLNamedIndividual, direct: bool = False) -> Iterable[owlapy.class_expression.OWLClass] Gets the named classes which are (potentially direct) types of the specified named individual. :param ind: The individual whose types are to be retrieved. :param direct: Specifies if the direct types should be retrieved (True), or if all types should be retrieved (False). :returns: If direct is True, each named class C where the set of reasoner axioms entails DirectClassAssertion(C, ind). If direct is False, each named class C where the set of reasoner axioms entails ClassAssertion(C, ind). .. py:method:: get_root_ontology() -> owlapy.owl_ontology.OWLOntology Gets the "root" ontology that is loaded into this reasoner. The reasoner takes into account the axioms in this ontology and its import's closure. .. py:method:: is_isolated() Return True if this reasoner is using an isolated ontology. .. py:method:: is_using_triplestore() Return True if this reasoner is using a triplestore to retrieve instances. .. py:class:: OWLOntology_Owlready2(manager: OWLOntologyManager_Owlready2, ontology_iri: owlapy.iri.IRI, load: bool) Bases: :py:obj:`owlapy.owl_ontology.OWLOntology` Represents an OWL 2 Ontology in the OWL 2 specification. An OWLOntology consists of a possibly empty set of OWLAxioms and a possibly empty set of OWLAnnotations. An ontology can have an ontology IRI which can be used to identify the ontology. If it has an ontology IRI then it may also have an ontology version IRI. Since OWL 2, an ontology need not have an ontology IRI. (See the OWL 2 Structural Specification). An ontology cannot be modified directly. Changes must be applied via its OWLOntologyManager. .. py:attribute:: __slots__ :value: ('_manager', '_iri', '_world', '_onto') .. py:method:: classes_in_signature() -> Iterable[owlapy.class_expression.OWLClass] Gets the classes in the signature of this object. :returns: Classes in the signature of this object. .. py:method:: data_properties_in_signature() -> Iterable[owlapy.owl_property.OWLDataProperty] Get the data properties that are in the signature of this object. :returns: Data properties that are in the signature of this object. .. py:method:: object_properties_in_signature() -> Iterable[owlapy.owl_property.OWLObjectProperty] A convenience method that obtains the object properties that are in the signature of this object. :returns: Object properties that are in the signature of this object. .. py:method:: individuals_in_signature() -> Iterable[owlapy.owl_individual.OWLNamedIndividual] A convenience method that obtains the individuals that are in the signature of this object. :returns: Individuals that are in the signature of this object. .. py:method:: equivalent_classes_axioms(c: owlapy.class_expression.OWLClass) -> Iterable[owlapy.owl_axiom.OWLEquivalentClassesAxiom] Gets all of the equivalent axioms in this ontology that contain the specified class as an operand. :param c: The class for which the EquivalentClasses axioms should be retrieved. :returns: EquivalentClasses axioms contained in this ontology. .. py:method:: general_class_axioms() -> Iterable[owlapy.owl_axiom.OWLClassAxiom] Get the general class axioms of this ontology. This includes SubClass axioms with a complex class expression as the sub class and EquivalentClass axioms and DisjointClass axioms with only complex class expressions. :returns: General class axioms contained in this ontology. .. py:method:: get_owl_ontology_manager() -> OWLOntologyManager_Owlready2 Gets the manager that manages this ontology. .. py:method:: get_ontology_id() -> owlapy.owl_ontology.OWLOntologyID Gets the OWLOntologyID belonging to this object. :returns: The OWLOntologyID. .. py:method:: data_property_domain_axioms(pe: owlapy.owl_property.OWLDataProperty) -> Iterable[owlapy.owl_axiom.OWLDataPropertyDomainAxiom] Gets the OWLDataPropertyDomainAxiom objects where the property is equal to the specified property. :param property: The property which is equal to the property of the retrieved axioms. :returns: The axioms matching the search. .. py:method:: data_property_range_axioms(pe: owlapy.owl_property.OWLDataProperty) -> Iterable[owlapy.owl_axiom.OWLDataPropertyRangeAxiom] Gets the OWLDataPropertyRangeAxiom objects where the property is equal to the specified property. :param property: The property which is equal to the property of the retrieved axioms. :returns: The axioms matching the search. .. py:method:: object_property_domain_axioms(pe: owlapy.owl_property.OWLObjectProperty) -> Iterable[owlapy.owl_axiom.OWLObjectPropertyDomainAxiom] Gets the OWLObjectPropertyDomainAxiom objects where the property is equal to the specified property. :param property: The property which is equal to the property of the retrieved axioms. :returns: The axioms matching the search. .. py:method:: object_property_range_axioms(pe: owlapy.owl_property.OWLObjectProperty) -> Iterable[owlapy.owl_axiom.OWLObjectPropertyRangeAxiom] Gets the OWLObjectPropertyRangeAxiom objects where the property is equal to the specified property. :param property: The property which is equal to the property of the retrieved axioms. :returns: The axioms matching the search. .. py:method:: get_original_iri() Get the IRI argument that was used to create this ontology. .. py:method:: __eq__(other) Return self==value. .. py:method:: __hash__() Return hash(self). .. py:method:: __repr__() Return repr(self). .. py:class:: BaseReasoner_Owlready2 Bases: :py:obj:`enum.Enum` Enumeration class for base reasoner when calling sync_reasoner. .. attribute:: PELLET Pellet base reasoner. .. attribute:: HERMIT HermiT base reasoner. .. py:attribute:: PELLET .. py:attribute:: HERMIT .. py:class:: OWLReasoner_Owlready2_ComplexCEInstances(ontology: ontolearn.base.OWLOntology_Owlready2, base_reasoner: Optional[ontolearn.base.BaseReasoner_Owlready2] = None, infer_property_values: bool = True, infer_data_property_values: bool = True, isolate: bool = False) Bases: :py:obj:`ontolearn.base.OWLReasoner_Owlready2` Extra convenience methods for OWL Reasoners (Not part of OWLAPI) .. py:attribute:: __slots__ :value: ('_cnt', '_conv', '_base_reasoner') .. py:method:: update_isolated_ontology(axioms_to_add: List[owlapy.owl_axiom.OWLAxiom] = None, axioms_to_remove: List[owlapy.owl_axiom.OWLAxiom] = None) Add or remove axioms to the isolated ontology that the reasoner is using. :param axioms_to_add: Axioms to add to the isolated ontology. :type axioms_to_add: List[OWLAxiom] :param axioms_to_remove: Axioms to remove from the isolated ontology. :type axioms_to_remove: List[OWLAxiom] .. py:method:: instances(ce: owlapy.class_expression.OWLClassExpression, direct: bool = False) -> Iterable[owlapy.owl_individual.OWLNamedIndividual] Gets the individuals which are instances of the specified class expression. :param ce: The class expression whose instances are to be retrieved. :param direct: Specifies if the direct instances should be retrieved (True), or if all instances should be retrieved (False). :returns: If direct is True, each named individual j where the set of reasoner axioms entails DirectClassAssertion(ce, j). If direct is False, each named individual j where the set of reasoner axioms entails ClassAssertion(ce, j). If ce is unsatisfiable with respect to the set of reasoner axioms then nothing returned. .. py:method:: __del__() .. py:class:: OWLReasoner_FastInstanceChecker(ontology: owlapy.owl_ontology.OWLOntology, base_reasoner: owlapy.owl_reasoner.OWLReasoner, *, property_cache: bool = True, negation_default: bool = True, sub_properties: bool = False) Bases: :py:obj:`ontolearn.base.ext.OWLReasonerEx` Tries to check instances fast (but maybe incomplete). .. py:attribute:: __slots__ :value: ('_ontology', '_base_reasoner', '_ind_set', '_cls_to_ind', '_has_prop',... .. py:method:: reset() The reset method shall reset any cached state. .. py:method:: is_isolated() Return True if this reasoner is using an isolated ontology. .. py:method:: is_using_triplestore() Return True if this reasoner is using a triplestore to retrieve instances. .. py:method:: data_property_domains(pe: owlapy.owl_property.OWLDataProperty, direct: bool = False) -> Iterable[owlapy.class_expression.OWLClassExpression] Gets the class expressions that are the direct or indirect domains of this property with respect to the imports closure of the root ontology. :param pe: The property expression whose domains are to be retrieved. :param direct: Specifies if the direct domains should be retrieved (True), or if all domains should be retrieved (False). :returns: Let N = equivalent_classes(DataSomeValuesFrom(pe rdfs:Literal)). If direct is True: then if N is not empty then the return value is N, else the return value is the result of super_classes(DataSomeValuesFrom(pe rdfs:Literal), true). If direct is False: then the result of super_classes(DataSomeValuesFrom(pe rdfs:Literal), false) together with N if N is non-empty. (Note, rdfs:Literal is the top datatype). .. py:method:: data_property_ranges(pe: owlapy.owl_property.OWLDataProperty, direct: bool = False) -> Iterable[owlapy.owl_data_ranges.OWLDataRange] Gets the data ranges that are the direct or indirect ranges of this property with respect to the imports closure of the root ontology. :param pe: The property expression whose ranges are to be retrieved. :param direct: Specifies if the direct ranges should be retrieved (True), or if all ranges should be retrieved (False). Returns: .. py:method:: object_property_domains(pe: owlapy.owl_property.OWLObjectProperty, direct: bool = False) -> Iterable[owlapy.class_expression.OWLClassExpression] Gets the class expressions that are the direct or indirect domains of this property with respect to the imports closure of the root ontology. :param pe: The property expression whose domains are to be retrieved. :param direct: Specifies if the direct domains should be retrieved (True), or if all domains should be retrieved (False). :returns: Let N = equivalent_classes(ObjectSomeValuesFrom(pe owl:Thing)). If direct is True: then if N is not empty then the return value is N, else the return value is the result of super_classes(ObjectSomeValuesFrom(pe owl:Thing), true). If direct is False: then the result of super_classes(ObjectSomeValuesFrom(pe owl:Thing), false) together with N if N is non-empty. .. py:method:: object_property_ranges(pe: owlapy.owl_property.OWLObjectProperty, direct: bool = False) -> Iterable[owlapy.class_expression.OWLClassExpression] Gets the class expressions that are the direct or indirect ranges of this property with respect to the imports closure of the root ontology. :param pe: The property expression whose ranges are to be retrieved. :param direct: Specifies if the direct ranges should be retrieved (True), or if all ranges should be retrieved (False). :returns: Let N = equivalent_classes(ObjectSomeValuesFrom(ObjectInverseOf(pe) owl:Thing)). If direct is True: then if N is not empty then the return value is N, else the return value is the result of super_classes(ObjectSomeValuesFrom(ObjectInverseOf(pe) owl:Thing), true). If direct is False: then the result of super_classes(ObjectSomeValuesFrom(ObjectInverseOf(pe) owl:Thing), false) together with N if N is non-empty. .. py:method:: equivalent_classes(ce: owlapy.class_expression.OWLClassExpression, only_named: bool = True) -> Iterable[owlapy.class_expression.OWLClassExpression] Gets the class expressions that are equivalent to the specified class expression with respect to the set of reasoner axioms. :param ce: The class expression whose equivalent classes are to be retrieved. :param only_named: Whether to only retrieve named equivalent classes or also complex class expressions. :returns: All class expressions C where the root ontology imports closure entails EquivalentClasses(ce C). If ce is not a class name (i.e. it is an anonymous class expression) and there are no such classes C then there will be no result. If ce is unsatisfiable with respect to the set of reasoner axioms then owl:Nothing, i.e. the bottom node, will be returned. .. py:method:: disjoint_classes(ce: owlapy.class_expression.OWLClassExpression, only_named: bool = True) -> Iterable[owlapy.class_expression.OWLClassExpression] Gets the class expressions that are disjoint with specified class expression with respect to the set of reasoner axioms. :param ce: The class expression whose disjoint classes are to be retrieved. :param only_named: Whether to only retrieve named disjoint classes or also complex class expressions. :returns: All class expressions D where the set of reasoner axioms entails EquivalentClasses(D ObjectComplementOf(ce)) or StrictSubClassOf(D ObjectComplementOf(ce)). .. py:method:: different_individuals(ce: owlapy.owl_individual.OWLNamedIndividual) -> Iterable[owlapy.owl_individual.OWLNamedIndividual] Gets the individuals that are different from the specified individual with respect to the set of reasoner axioms. :param ind: The individual whose different individuals are to be retrieved. :returns: All individuals x where the set of reasoner axioms entails DifferentIndividuals(ind x). .. py:method:: same_individuals(ce: owlapy.owl_individual.OWLNamedIndividual) -> Iterable[owlapy.owl_individual.OWLNamedIndividual] Gets the individuals that are the same as the specified individual with respect to the set of reasoner axioms. :param ind: The individual whose same individuals are to be retrieved. :returns: All individuals x where the root ontology imports closure entails SameIndividual(ind x). .. py:method:: data_property_values(ind: owlapy.owl_individual.OWLNamedIndividual, pe: owlapy.owl_property.OWLDataProperty, direct: bool = True) -> Iterable[owlapy.owl_literal.OWLLiteral] Gets the data property values for the specified individual and data property expression. :param ind: The individual that is the subject of the data property values. :param pe: The data property expression whose values are to be retrieved for the specified individual. :param direct: Specifies if the direct values should be retrieved (True), or if all values should be retrieved (False), so that sub properties are taken into account. :returns: A set of OWLLiterals containing literals such that for each literal l in the set, the set of reasoner axioms entails DataPropertyAssertion(pe ind l). .. py:method:: all_data_property_values(pe: owlapy.owl_property.OWLDataProperty, direct: bool = True) -> Iterable[owlapy.owl_literal.OWLLiteral] Gets all values for the given data property expression that appear in the knowledge base. :param pe: The data property expression whose values are to be retrieved :param direct: Specifies if only the direct values of the data property pe should be retrieved (True), or if the values of sub properties of pe should be taken into account (False). :returns: A set of OWLLiterals containing literals such that for each literal l in the set, the set of reasoner axioms entails DataPropertyAssertion(pe ind l) for any ind. .. py:method:: object_property_values(ind: owlapy.owl_individual.OWLNamedIndividual, pe: owlapy.owl_property.OWLObjectPropertyExpression, direct: bool = True) -> Iterable[owlapy.owl_individual.OWLNamedIndividual] Gets the object property values for the specified individual and object property expression. :param ind: The individual that is the subject of the object property values. :param pe: The object property expression whose values are to be retrieved for the specified individual. :param direct: Specifies if the direct values should be retrieved (True), or if all values should be retrieved (False), so that sub properties are taken into account. :returns: The named individuals such that for each individual j, the set of reasoner axioms entails ObjectPropertyAssertion(pe ind j). .. py:method:: flush() -> None Flushes any changes stored in the buffer, which causes the reasoner to take into consideration the changes the current root ontology specified by the changes. .. py:method:: instances(ce: owlapy.class_expression.OWLClassExpression, direct: bool = False) -> Iterable[owlapy.owl_individual.OWLNamedIndividual] Gets the individuals which are instances of the specified class expression. :param ce: The class expression whose instances are to be retrieved. :param direct: Specifies if the direct instances should be retrieved (True), or if all instances should be retrieved (False). :returns: If direct is True, each named individual j where the set of reasoner axioms entails DirectClassAssertion(ce, j). If direct is False, each named individual j where the set of reasoner axioms entails ClassAssertion(ce, j). If ce is unsatisfiable with respect to the set of reasoner axioms then nothing returned. .. py:method:: sub_classes(ce: owlapy.class_expression.OWLClassExpression, direct: bool = False, only_named: bool = True) -> Iterable[owlapy.class_expression.OWLClassExpression] Gets the set of named classes that are the strict (potentially direct) subclasses of the specified class expression with respect to the reasoner axioms. :param ce: The class expression whose strict (direct) subclasses are to be retrieved. :param direct: Specifies if the direct subclasses should be retrieved (True) or if the all subclasses (descendant) classes should be retrieved (False). :param only_named: Whether to only retrieve named sub-classes or also complex class expressions. :returns: If direct is True, each class C where reasoner axioms entails DirectSubClassOf(C, ce). If direct is False, each class C where reasoner axioms entails StrictSubClassOf(C, ce). If ce is equivalent to owl:Nothing then nothing will be returned. .. py:method:: super_classes(ce: owlapy.class_expression.OWLClassExpression, direct: bool = False, only_named: bool = True) -> Iterable[owlapy.class_expression.OWLClassExpression] Gets the stream of named classes that are the strict (potentially direct) super classes of the specified class expression with respect to the imports closure of the root ontology. :param ce: The class expression whose strict (direct) super classes are to be retrieved. :param direct: Specifies if the direct super classes should be retrieved (True) or if the all super classes (ancestors) classes should be retrieved (False). :param only_named: Whether to only retrieve named super classes or also complex class expressions. :returns: If direct is True, each class C where the set of reasoner axioms entails DirectSubClassOf(ce, C). If direct is False, each class C where set of reasoner axioms entails StrictSubClassOf(ce, C). If ce is equivalent to owl:Thing then nothing will be returned. .. py:method:: types(ind: owlapy.owl_individual.OWLNamedIndividual, direct: bool = False) -> Iterable[owlapy.class_expression.OWLClass] Gets the named classes which are (potentially direct) types of the specified named individual. :param ind: The individual whose types are to be retrieved. :param direct: Specifies if the direct types should be retrieved (True), or if all types should be retrieved (False). :returns: If direct is True, each named class C where the set of reasoner axioms entails DirectClassAssertion(C, ind). If direct is False, each named class C where the set of reasoner axioms entails ClassAssertion(C, ind). .. py:method:: equivalent_object_properties(dp: owlapy.owl_property.OWLObjectPropertyExpression) -> Iterable[owlapy.owl_property.OWLObjectPropertyExpression] Gets the simplified object properties that are equivalent to the specified object property with respect to the set of reasoner axioms. :param op: The object property whose equivalent object properties are to be retrieved. :returns: All simplified object properties e where the root ontology imports closure entails EquivalentObjectProperties(op e). If op is unsatisfiable with respect to the set of reasoner axioms then owl:bottomDataProperty will be returned. .. py:method:: equivalent_data_properties(dp: owlapy.owl_property.OWLDataProperty) -> Iterable[owlapy.owl_property.OWLDataProperty] Gets the data properties that are equivalent to the specified data property with respect to the set of reasoner axioms. :param dp: The data property whose equivalent data properties are to be retrieved. :returns: All data properties e where the root ontology imports closure entails EquivalentDataProperties(dp e). If dp is unsatisfiable with respect to the set of reasoner axioms then owl:bottomDataProperty will be returned. .. py:method:: disjoint_object_properties(dp: owlapy.owl_property.OWLObjectPropertyExpression) -> Iterable[owlapy.owl_property.OWLObjectPropertyExpression] Gets the simplified object properties that are disjoint with the specified object property with respect to the set of reasoner axioms. :param op: The object property whose disjoint object properties are to be retrieved. :returns: All simplified object properties e where the root ontology imports closure entails EquivalentObjectProperties(e ObjectPropertyComplementOf(op)) or StrictSubObjectPropertyOf(e ObjectPropertyComplementOf(op)). .. py:method:: disjoint_data_properties(dp: owlapy.owl_property.OWLDataProperty) -> Iterable[owlapy.owl_property.OWLDataProperty] Gets the data properties that are disjoint with the specified data property with respect to the set of reasoner axioms. :param dp: The data property whose disjoint data properties are to be retrieved. :returns: All data properties e where the root ontology imports closure entails EquivalentDataProperties(e DataPropertyComplementOf(dp)) or StrictSubDataPropertyOf(e DataPropertyComplementOf(dp)). .. py:method:: sub_data_properties(dp: owlapy.owl_property.OWLDataProperty, direct: bool = False) -> Iterable[owlapy.owl_property.OWLDataProperty] Gets the set of named data properties that are the strict (potentially direct) subproperties of the specified data property expression with respect to the imports closure of the root ontology. :param dp: The data property whose strict (direct) subproperties are to be retrieved. :param direct: Specifies if the direct subproperties should be retrieved (True) or if the all subproperties (descendants) should be retrieved (False). :returns: If direct is True, each property P where the set of reasoner axioms entails DirectSubDataPropertyOf(P, pe). If direct is False, each property P where the set of reasoner axioms entails StrictSubDataPropertyOf(P, pe). If pe is equivalent to owl:bottomDataProperty then nothing will be returned. .. py:method:: super_data_properties(dp: owlapy.owl_property.OWLDataProperty, direct: bool = False) -> Iterable[owlapy.owl_property.OWLDataProperty] Gets the stream of data properties that are the strict (potentially direct) super properties of the specified data property with respect to the imports closure of the root ontology. :param dp: The data property whose super properties are to be retrieved. :type dp: OWLDataProperty :param direct: Specifies if the direct super properties should be retrieved (True) or if the all super properties (ancestors) should be retrieved (False). :type direct: bool :returns: Iterable of super properties. .. py:method:: super_object_properties(op: owlapy.owl_property.OWLObjectProperty, direct: bool = False) -> Iterable[owlapy.owl_property.OWLDataProperty] Gets the stream of object properties that are the strict (potentially direct) super properties of the specified object property with respect to the imports closure of the root ontology. :param op: The object property expression whose super properties are to be retrieved. :type op: OWLObjectPropertyExpression :param direct: Specifies if the direct super properties should be retrieved (True) or if the all super properties (ancestors) should be retrieved (False). :type direct: bool :returns: Iterable of super properties. .. py:method:: sub_object_properties(op: owlapy.owl_property.OWLObjectPropertyExpression, direct: bool = False) -> Iterable[owlapy.owl_property.OWLObjectPropertyExpression] Gets the stream of simplified object property expressions that are the strict (potentially direct) subproperties of the specified object property expression with respect to the imports closure of the root ontology. :param op: The object property expression whose strict (direct) subproperties are to be retrieved. :param direct: Specifies if the direct subproperties should be retrieved (True) or if the all subproperties (descendants) should be retrieved (False). :returns: If direct is True, simplified object property expressions, such that for each simplified object property expression, P, the set of reasoner axioms entails DirectSubObjectPropertyOf(P, pe). If direct is False, simplified object property expressions, such that for each simplified object property expression, P, the set of reasoner axioms entails StrictSubObjectPropertyOf(P, pe). If pe is equivalent to owl:bottomObjectProperty then nothing will be returned. .. py:method:: get_root_ontology() -> owlapy.owl_ontology.OWLOntology Gets the "root" ontology that is loaded into this reasoner. The reasoner takes into account the axioms in this ontology and its import's closure.