ontolearn.triple_store

Triple store representations.

Module Contents

Classes

TripleStoreOntology

Represents an OWL 2 Ontology in the OWL 2 specification.

TripleStoreReasoner

Extra convenience methods for OWL Reasoners

TripleStoreKnowledgeBase

Representation of an OWL knowledge base in Ontolearn.

TripleStoreReasonerOntology

TripleStore

triple store

Functions

rdflib_to_str(→ str)

@TODO: CD: Not quite sure whether we need this continuent function

is_valid_url(→ bool)

Check the validity of a URL.

get_results_from_ts(triplestore_address, query, ...)

Execute the SPARQL query in the given triplestore_address and return the result as the given return_type.

unwrap(result)

suf(direct)

Put the star for rdfs properties depending on direct param

Attributes

logger

rdfs_prefix

owl_prefix

rdf_prefix

xsd_prefix

limit_posix

ontolearn.triple_store.logger
ontolearn.triple_store.rdfs_prefix = Multiline-String
Show Value
"""PREFIX  rdfs: <http://www.w3.org/2000/01/rdf-schema#>
 """
ontolearn.triple_store.owl_prefix = Multiline-String
Show Value
"""PREFIX owl: <http://www.w3.org/2002/07/owl#>
 """
ontolearn.triple_store.rdf_prefix = Multiline-String
Show Value
"""PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
 """
ontolearn.triple_store.xsd_prefix = 'PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\n'
ontolearn.triple_store.limit_posix = ''
ontolearn.triple_store.rdflib_to_str(sparql_result: rdflib.plugins.sparql.processor.SPARQLResult) str[source]

@TODO: CD: Not quite sure whether we need this continuent function

ontolearn.triple_store.is_valid_url(url) bool[source]

Check the validity of a URL.

Parameters:

url (str) – The url to validate.

Returns:

True if url is not None, and it passes the regex check.

ontolearn.triple_store.get_results_from_ts(triplestore_address: str, query: str, return_type: type)[source]

Execute the SPARQL query in the given triplestore_address and return the result as the given return_type.

Parameters:
  • triplestore_address (str) – The triplestore address where the query will be executed.

  • query (str) – SPARQL query where the root variable should be ‘?x’.

  • return_type (type) – OWLAPY class as type. e.g. OWLClass, OWLNamedIndividual, etc.

Returns:

Generator containing the results of the query as the given type.

ontolearn.triple_store.unwrap(result: requests.Response)[source]
ontolearn.triple_store.suf(direct: bool)[source]

Put the star for rdfs properties depending on direct param

class ontolearn.triple_store.TripleStoreOntology(triplestore_address: str)[source]

Bases: 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.

classes_in_signature() Iterable[owlapy.class_expression.OWLClass][source]

Gets the classes in the signature of this object.

Returns:

Classes in the signature of this object.

data_properties_in_signature() Iterable[owlapy.owl_property.OWLDataProperty][source]

Get the data properties that are in the signature of this object.

Returns:

Data properties that are in the signature of this object.

object_properties_in_signature() Iterable[owlapy.owl_property.OWLObjectProperty][source]

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.

individuals_in_signature() Iterable[owlapy.owl_individual.OWLNamedIndividual][source]

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.

equivalent_classes_axioms(c: owlapy.class_expression.OWLClass) Iterable[owlapy.owl_axiom.OWLEquivalentClassesAxiom][source]

Gets all of the equivalent axioms in this ontology that contain the specified class as an operand.

Parameters:

c – The class for which the EquivalentClasses axioms should be retrieved.

Returns:

EquivalentClasses axioms contained in this ontology.

abstract general_class_axioms() Iterable[owlapy.owl_axiom.OWLClassAxiom][source]
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.

data_property_domain_axioms(pe: owlapy.owl_property.OWLDataProperty) Iterable[owlapy.owl_axiom.OWLDataPropertyDomainAxiom][source]

Gets the OWLDataPropertyDomainAxiom objects where the property is equal to the specified property.

Parameters:

property – The property which is equal to the property of the retrieved axioms.

Returns:

The axioms matching the search.

abstract data_property_range_axioms(pe: owlapy.owl_property.OWLDataProperty) Iterable[owlapy.owl_axiom.OWLDataPropertyRangeAxiom][source]

Gets the OWLDataPropertyRangeAxiom objects where the property is equal to the specified property.

Parameters:

property – The property which is equal to the property of the retrieved axioms.

Returns:

The axioms matching the search.

object_property_domain_axioms(pe: owlapy.owl_property.OWLObjectProperty) Iterable[owlapy.owl_axiom.OWLObjectPropertyDomainAxiom][source]

Gets the OWLObjectPropertyDomainAxiom objects where the property is equal to the specified property.

Parameters:

property – The property which is equal to the property of the retrieved axioms.

Returns:

The axioms matching the search.

object_property_range_axioms(pe: owlapy.owl_property.OWLObjectProperty) Iterable[owlapy.owl_axiom.OWLObjectPropertyRangeAxiom][source]

Gets the OWLObjectPropertyRangeAxiom objects where the property is equal to the specified property.

Parameters:

property – The property which is equal to the property of the retrieved axioms.

Returns:

The axioms matching the search.

get_owl_ontology_manager()[source]

Gets the manager that manages this ontology.

abstract get_ontology_id() owlapy.owl_ontology.OWLOntologyID[source]

Gets the OWLOntologyID belonging to this object.

Returns:

The OWLOntologyID.

__eq__(other)[source]

Return self==value.

__hash__()[source]

Return hash(self).

__repr__()[source]

Return repr(self).

class ontolearn.triple_store.TripleStoreReasoner(ontology: TripleStoreOntology)[source]

Bases: ontolearn.base.ext.OWLReasonerEx

Extra convenience methods for OWL Reasoners

(Not part of OWLAPI)

__slots__ = 'ontology'
data_property_domains(pe: owlapy.owl_property.OWLDataProperty, direct: bool = False) Iterable[owlapy.class_expression.OWLClassExpression][source]
Gets the class expressions that are the direct or indirect domains of this property with respect to the

imports closure of the root ontology.

Parameters:
  • pe – The property expression whose domains are to be retrieved.

  • 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).

object_property_domains(pe: owlapy.owl_property.OWLObjectProperty, direct: bool = False) Iterable[owlapy.class_expression.OWLClassExpression][source]
Gets the class expressions that are the direct or indirect domains of this property with respect to the

imports closure of the root ontology.

Parameters:
  • pe – The property expression whose domains are to be retrieved.

  • 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.

object_property_ranges(pe: owlapy.owl_property.OWLObjectProperty, direct: bool = False) Iterable[owlapy.class_expression.OWLClassExpression][source]
Gets the class expressions that are the direct or indirect ranges of this property with respect to the

imports closure of the root ontology.

Parameters:
  • pe – The property expression whose ranges are to be retrieved.

  • 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.

equivalent_classes(ce: owlapy.class_expression.OWLClassExpression, only_named: bool = True) Iterable[owlapy.class_expression.OWLClassExpression][source]

Gets the class expressions that are equivalent to the specified class expression with respect to the set of reasoner axioms.

Parameters:
  • ce – The class expression whose equivalent classes are to be retrieved.

  • 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.

disjoint_classes(ce: owlapy.class_expression.OWLClassExpression, only_named: bool = True) Iterable[owlapy.class_expression.OWLClassExpression][source]

Gets the class expressions that are disjoint with specified class expression with respect to the set of reasoner axioms.

Parameters:
  • ce – The class expression whose disjoint classes are to be retrieved.

  • 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)).

different_individuals(ind: owlapy.owl_individual.OWLNamedIndividual) Iterable[owlapy.owl_individual.OWLNamedIndividual][source]

Gets the individuals that are different from the specified individual with respect to the set of reasoner axioms.

Parameters:

ind – The individual whose different individuals are to be retrieved.

Returns:

All individuals x where the set of reasoner axioms entails DifferentIndividuals(ind x).

same_individuals(ind: owlapy.owl_individual.OWLNamedIndividual) Iterable[owlapy.owl_individual.OWLNamedIndividual][source]

Gets the individuals that are the same as the specified individual with respect to the set of reasoner axioms.

Parameters:

ind – The individual whose same individuals are to be retrieved.

Returns:

All individuals x where the root ontology imports closure entails SameIndividual(ind x).

equivalent_object_properties(op: owlapy.owl_property.OWLObjectPropertyExpression) Iterable[owlapy.owl_property.OWLObjectPropertyExpression][source]

Gets the simplified object properties that are equivalent to the specified object property with respect to the set of reasoner axioms.

Parameters:

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.

equivalent_data_properties(dp: owlapy.owl_property.OWLDataProperty) Iterable[owlapy.owl_property.OWLDataProperty][source]

Gets the data properties that are equivalent to the specified data property with respect to the set of reasoner axioms.

Parameters:

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.

data_property_values(ind: owlapy.owl_individual.OWLNamedIndividual, pe: owlapy.owl_property.OWLDataProperty, direct: bool = True) Iterable[owlapy.owl_literal.OWLLiteral][source]

Gets the data property values for the specified individual and data property expression.

Parameters:
  • ind – The individual that is the subject of the data property values.

  • pe – The data property expression whose values are to be retrieved for the specified individual.

  • 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).

object_property_values(ind: owlapy.owl_individual.OWLNamedIndividual, pe: owlapy.owl_property.OWLObjectPropertyExpression, direct: bool = True) Iterable[owlapy.owl_individual.OWLNamedIndividual][source]

Gets the object property values for the specified individual and object property expression.

Parameters:
  • ind – The individual that is the subject of the object property values.

  • pe – The object property expression whose values are to be retrieved for the specified individual.

  • 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).

flush() None[source]

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.

instances(ce: owlapy.class_expression.OWLClassExpression, direct: bool = False, seen_set: Set = None) Iterable[owlapy.owl_individual.OWLNamedIndividual][source]

Gets the individuals which are instances of the specified class expression.

Parameters:
  • ce – The class expression whose instances are to be retrieved.

  • 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.

sub_classes(ce: owlapy.class_expression.OWLClassExpression, direct: bool = False, only_named: bool = True) Iterable[owlapy.class_expression.OWLClassExpression][source]

Gets the set of named classes that are the strict (potentially direct) subclasses of the specified class expression with respect to the reasoner axioms.

Parameters:
  • ce – The class expression whose strict (direct) subclasses are to be retrieved.

  • direct – Specifies if the direct subclasses should be retrieved (True) or if the all subclasses (descendant) classes should be retrieved (False).

  • 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.

super_classes(ce: owlapy.class_expression.OWLClassExpression, direct: bool = False, only_named: bool = True) Iterable[owlapy.class_expression.OWLClassExpression][source]

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.

Parameters:
  • ce – The class expression whose strict (direct) super classes are to be retrieved.

  • direct – Specifies if the direct super classes should be retrieved (True) or if the all super classes (ancestors) classes should be retrieved (False).

  • 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.

disjoint_object_properties(op: owlapy.owl_property.OWLObjectPropertyExpression) Iterable[owlapy.owl_property.OWLObjectPropertyExpression][source]

Gets the simplified object properties that are disjoint with the specified object property with respect to the set of reasoner axioms.

Parameters:

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)).

disjoint_data_properties(dp: owlapy.owl_property.OWLDataProperty) Iterable[owlapy.owl_property.OWLDataProperty][source]

Gets the data properties that are disjoint with the specified data property with respect to the set of reasoner axioms.

Parameters:

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)).

all_data_property_values(pe: owlapy.owl_property.OWLDataProperty, direct: bool = True) Iterable[owlapy.owl_literal.OWLLiteral][source]

Gets all values for the given data property expression that appear in the knowledge base.

Parameters:
  • pe – The data property expression whose values are to be retrieved

  • 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.

sub_data_properties(dp: owlapy.owl_property.OWLDataProperty, direct: bool = False) Iterable[owlapy.owl_property.OWLDataProperty][source]

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.

Parameters:
  • dp – The data property whose strict (direct) subproperties are to be retrieved.

  • 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.

super_data_properties(dp: owlapy.owl_property.OWLDataProperty, direct: bool = False) Iterable[owlapy.owl_property.OWLDataProperty][source]

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.

Parameters:
  • dp (OWLDataProperty) – The data property whose super properties are to be retrieved.

  • direct (bool) – Specifies if the direct super properties should be retrieved (True) or if the all super properties (ancestors) should be retrieved (False).

Returns:

Iterable of super properties.

sub_object_properties(op: owlapy.owl_property.OWLObjectPropertyExpression, direct: bool = False) Iterable[owlapy.owl_property.OWLObjectPropertyExpression][source]

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.

Parameters:
  • op – The object property expression whose strict (direct) subproperties are to be retrieved.

  • 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.

super_object_properties(op: owlapy.owl_property.OWLObjectPropertyExpression, direct: bool = False) Iterable[owlapy.owl_property.OWLObjectPropertyExpression][source]

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.

Parameters:
  • op (OWLObjectPropertyExpression) – The object property expression whose super properties are to be retrieved.

  • direct (bool) – Specifies if the direct super properties should be retrieved (True) or if the all super properties (ancestors) should be retrieved (False).

Returns:

Iterable of super properties.

types(ind: owlapy.owl_individual.OWLNamedIndividual, direct: bool = False) Iterable[owlapy.class_expression.OWLClass][source]

Gets the named classes which are (potentially direct) types of the specified named individual.

Parameters:
  • ind – The individual whose types are to be retrieved.

  • 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).

get_root_ontology() owlapy.owl_ontology.OWLOntology[source]

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.

is_isolated()[source]

Return True if this reasoner is using an isolated ontology.

is_using_triplestore()[source]

No use! Deprecated.

class ontolearn.triple_store.TripleStoreKnowledgeBase(triplestore_address: str)[source]

Bases: ontolearn.knowledge_base.KnowledgeBase

Representation of an OWL knowledge base in Ontolearn.

Parameters:
  • path – Path to an ontology file that is to be loaded.

  • ontologymanager_factory – Factory that creates an ontology manager to be used to load the file.

  • ontology – OWL ontology object.

  • reasoner_factory – Factory that creates a reasoner to reason about the ontology.

  • reasoner – reasoner Over the ontology.

  • length_metric_factory – See length_metric.

  • length_metric – Length metric that is used in calculation of class expression lengths.

  • individuals_cache_size – How many individuals of class expressions to cache.

  • backend_store – Whether to sync the world to backend store. reasoner of this object, if you enter a reasoner using :arg:`reasoner_factory` or :arg:`reasoner` argument it will override this setting.

  • include_implicit_individuals – Whether to identify and consider instances which are not set as OWL Named Individuals (does not contain this type) as individuals.

generator

Instance of concept generator.

Type:

ConceptGenerator

path

Path of the ontology file.

Type:

str

use_individuals_cache

Whether to use individuals cache to store individuals for method efficiency.

Type:

bool

url: str
ontology: TripleStoreOntology
reasoner: TripleStoreReasoner
class ontolearn.triple_store.TripleStoreReasonerOntology(graph: rdflib.graph.Graph = None, url: str = None)[source]
concise_bounded_description(str_iri: str) Generator[Tuple[owlapy.owl_individual.OWLNamedIndividual, owlapy.iri.IRI | owlapy.owl_property.OWLObjectProperty, owlapy.class_expression.OWLClass | owlapy.owl_individual.OWLNamedIndividual], None, None][source]

https://www.w3.org/submissions/CBD/ also see https://docs.aws.amazon.com/neptune/latest/userguide/sparql-query-hints-for-describe.html

Given a particular node (the starting node) in a particular RDF graph (the source graph), a subgraph of that particular graph, taken to comprise a concise bounded description of the resource denoted by the starting node, can be identified as follows:

Include in the subgraph all statements in the source graph where the subject of the statement is the starting node; Recursively, for all statements identified in the subgraph thus far having a blank node object, include in the subgraph all statements in the source graph where the subject of the statement is the blank node in question and which are not already included in the subgraph. Recursively, for all statements included in the subgraph thus far, for all reifications of each statement in the source graph, include the concise bounded description beginning from the rdf:Statement node of each reification. his results in a subgraph where the object nodes are either URI references, literals, or blank nodes not serving as the subject of any statement in the graph.

abox(str_iri: str) Generator[Tuple[owlapy.owl_individual.OWLNamedIndividual, owlapy.iri.IRI | owlapy.owl_property.OWLObjectProperty, owlapy.class_expression.OWLClass | owlapy.owl_individual.OWLNamedIndividual], None, None][source]

Get all axioms of a given individual being a subject entity

Parameters:
  • str_iri (str) – An individual

  • mode (str) – The return format. 1) ‘native’ -> returns triples as tuples of owlapy objects, 2) ‘iri’ -> returns triples as tuples of IRIs as string, 3) ‘axiom’ -> triples are represented by owlapy axioms.

Returns: Iterable of tuples or owlapy axiom, depending on the mode.

query(sparql_query: str)[source]
classes_in_signature() Iterable[owlapy.class_expression.OWLClass][source]
subconcepts(named_concept: owlapy.class_expression.OWLClass, direct=True)[source]
get_type_individuals(individual: str)[source]
instances(expression: owlapy.class_expression.OWLClassExpression) Generator[owlapy.owl_individual.OWLNamedIndividual, None, None][source]
individuals_in_signature() Generator[owlapy.owl_individual.OWLNamedIndividual, None, None][source]
data_properties_in_signature() Iterable[owlapy.owl_property.OWLDataProperty][source]
object_properties_in_signature() Iterable[owlapy.owl_property.OWLObjectProperty][source]
boolean_data_properties()[source]
class ontolearn.triple_store.TripleStore(path: str = None, url: str = None)[source]

triple store

path: str
url: str
concise_bounded_description(individual: owlapy.owl_individual.OWLNamedIndividual, mode: str = 'native') Generator[Tuple[owlapy.owl_individual.OWLNamedIndividual, owlapy.iri.IRI | owlapy.owl_property.OWLObjectProperty, owlapy.class_expression.OWLClass | owlapy.owl_individual.OWLNamedIndividual], None, None][source]

Get the CBD (https://www.w3.org/submissions/CBD/) of a named individual.

Parameters:
  • individual (OWLNamedIndividual) – Individual to get the abox axioms from.

  • mode (str) – The return format. 1) ‘native’ -> returns triples as tuples of owlapy objects, 2) ‘iri’ -> returns triples as tuples of IRIs as string, 3) ‘axiom’ -> triples are represented by owlapy axioms.

Returns: Iterable of tuples or owlapy axiom, depending on the mode.

abox(individual: owlapy.owl_individual.OWLNamedIndividual, mode: str = 'native') Generator[Tuple[owlapy.owl_individual.OWLNamedIndividual, owlapy.iri.IRI | owlapy.owl_property.OWLObjectProperty, owlapy.class_expression.OWLClass | owlapy.owl_individual.OWLNamedIndividual], None, None][source]

Get all axioms of a given individual being a subject entity

Parameters:
  • individual (OWLNamedIndividual) – An individual

  • mode (str) – The return format. 1) ‘native’ -> returns triples as tuples of owlapy objects, 2) ‘iri’ -> returns triples as tuples of IRIs as string, 3) ‘axiom’ -> triples are represented by owlapy axioms. 4) ‘expression’ -> unique owl class expressions based on (1).

Returns: Iterable of tuples or owlapy axiom, depending on the mode.

get_object_properties()[source]
get_boolean_data_properties()[source]
individuals(concept: owlapy.class_expression.OWLClassExpression | None = None) Generator[owlapy.owl_individual.OWLNamedIndividual, None, None][source]

Given an OWL class expression, retrieve all individuals belonging to it. :param concept: Class expression of which to list individuals.

Returns:

Generator of individuals belonging to the given class.

get_types(ind: owlapy.owl_individual.OWLNamedIndividual, direct: True) Generator[owlapy.class_expression.OWLClass, None, None][source]
get_all_sub_concepts(concept: owlapy.class_expression.OWLClass, direct=True)[source]
named_concepts()[source]
quality_retrieval(expression: owlapy.class_expression.OWLClass, pos: set[owlapy.owl_individual.OWLNamedIndividual], neg: set[owlapy.owl_individual.OWLNamedIndividual])[source]
query(sparql: str) rdflib.plugins.sparql.processor.SPARQLResult[source]
concept_len(ce: owlapy.class_expression.OWLClassExpression) int[source]

Calculates the length of a concept and is used by some concept learning algorithms to find the best results considering also the length of the concepts.

Parameters:

ce – The concept to be measured.

Returns:

Length of the concept.

individuals_set(arg: Iterable[owlapy.owl_individual.OWLNamedIndividual] | owlapy.owl_individual.OWLNamedIndividual | owlapy.class_expression.OWLClassExpression) FrozenSet[source]

Retrieve the individuals specified in the arg as a frozenset. If arg is an OWLClassExpression then this method behaves as the method “individuals” but will return the final result as a frozenset.

Parameters:

arg – more than one individual/ single individual/ class expression of which to list individuals.

Returns:

Frozenset of the individuals depending on the arg type.

UPDATE: CD: This function should be deprecated it does not introduce any new functionality but coves a rewriting ,e .g. if args needs to be a frozen set, doing frozenset(arg) solves this need without introducing this function