owlapy

Submodules

Classes

OntologyManager

An OWLOntologyManager manages a set of ontologies. It is the main point for creating, loading and accessing

Functions

owl_expression_to_dl(→ str)

owl_expression_to_manchester(→ str)

dl_to_owl_expression(dl_expression, namespace)

manchester_to_owl_expression(manchester_expression, ...)

owl_expression_to_sparql(→ str)

Convert an OWL Class Expression (https://www.w3.org/TR/owl2-syntax/#Class_Expressions) into a SPARQL query

owl_expression_to_sparql_with_confusion_matrix(→ str)

Convert an OWL Class Expression (https://www.w3.org/TR/owl2-syntax/#Class_Expressions) into a SPARQL query

Package Contents

owlapy.owl_expression_to_dl(o: owlapy.owl_object.OWLObject) str[source]
owlapy.owl_expression_to_manchester(o: owlapy.owl_object.OWLObject) str[source]
owlapy.dl_to_owl_expression(dl_expression: str, namespace: str)[source]
owlapy.manchester_to_owl_expression(manchester_expression: str, namespace: str)[source]
owlapy.owl_expression_to_sparql(expression: owlapy.class_expression.OWLClassExpression = None, root_variable: str = '?x', values: Iterable[owlapy.owl_individual.OWLNamedIndividual] | None = None, for_all_de_morgan: bool = True, named_individuals: bool = False) str[source]

Convert an OWL Class Expression (https://www.w3.org/TR/owl2-syntax/#Class_Expressions) into a SPARQL query root variable: the variable that will be projected expression: the class expression to be transformed to a SPARQL query

values: positive or negative examples from a class expression problem. Unclear for_all_de_morgan: if set to True, the SPARQL mapping will use the mapping containing the nested FILTER NOT EXISTS patterns for the universal quantifier (¬(∃r.¬C)), instead of the counting query named_individuals: if set to True, the generated SPARQL query will return only entities that are instances of owl:NamedIndividual

owlapy.owl_expression_to_sparql_with_confusion_matrix(expression: owlapy.class_expression.OWLClassExpression, positive_examples: Iterable[owlapy.owl_individual.OWLNamedIndividual] | None, negative_examples: Iterable[owlapy.owl_individual.OWLNamedIndividual] | None, root_variable: str = '?x', for_all_de_morgan: bool = True, named_individuals: bool = False) str[source]

Convert an OWL Class Expression (https://www.w3.org/TR/owl2-syntax/#Class_Expressions) into a SPARQL query root variable: the variable that will be projected expression: the class expression to be transformed to a SPARQL query positive_examples: positive examples from a class expression problem negative_examples: positive examples from a class expression problem for_all_de_morgan: if set to True, the SPARQL mapping will use the mapping containing the nested FILTER NOT EXISTS patterns for the universal quantifier (¬(∃r.¬C)), instead of the counting query named_individuals: if set to True, the generated SPARQL query will return only entities that are instances of owl:NamedIndividual

class owlapy.OntologyManager(world_store=None)[source]

Bases: owlapy.abstracts.abstract_owl_ontology_manager.AbstractOWLOntologyManager

An OWLOntologyManager manages a set of ontologies. It is the main point for creating, loading and accessing ontologies.

__slots__ = '_world'
create_ontology(iri: str | owlapy.iri.IRI = None) owlapy.owl_ontology.Ontology[source]

Creates a new (empty) ontology that that has the specified ontology IRI (and no version IRI).

Parameters:

iri – The IRI of the ontology to be created, can also be a string.

Returns:

The newly created ontology.

load_ontology(path: owlapy.iri.IRI | str = None) owlapy.owl_ontology.Ontology[source]

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.

Parameters:

iri

The IRI that identifies the ontology, can also be a string.

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.

apply_change(change: owlapy.abstracts.abstract_owl_ontology_manager.AbstractOWLOntologyChange)[source]

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.

Parameters:

change – The change to be applied.

Raises:

ChangeApplied.UNSUCCESSFULLY – if the change was not applied successfully.

save_world()[source]

Saves the actual state of the quadstore in the SQLite3 file.