Skip to content

Commit

Permalink
WIP: Deprecating "Ontology Manager"
Browse files Browse the repository at this point in the history
  • Loading branch information
alkidbaci committed Feb 12, 2025
1 parent 46972e2 commit 729c4fc
Show file tree
Hide file tree
Showing 18 changed files with 157 additions and 288 deletions.
10 changes: 5 additions & 5 deletions examples/ontology_engineering.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from owlapy.class_expression import OWLClass
from owlapy.owl_axiom import OWLDeclarationAxiom, OWLClassAssertionAxiom
from owlapy.owl_individual import OWLNamedIndividual
from owlapy.owl_ontology_manager import OntologyManager
from owlapy.owl_ontology import Ontology
from owlapy.iri import IRI
from owlapy.static_funcs import download_external_files
# (1) Download the datasets if KGs does not exist.
download_external_files("https://files.dice-research.org/projects/Ontolearn/KGs.zip")
# (2) Load the father ontology using a new ontology manager.
onto = OntologyManager().load_ontology(path='file://../KGs/Family/father.owl')
# (2) Load the father ontology.
onto = Ontology('file://../KGs/Family/father.owl')
# (3) Iterate over defined OWL classes, object properties.
print("OWL Classes:")
for c in onto.classes_in_signature():
Expand Down Expand Up @@ -44,8 +44,8 @@
cdemir = OWLNamedIndividual('http://example.com/father#cdemir')
onto.add_axiom(OWLClassAssertionAxiom(cdemir, father))
# (9) Check whether cdemir is in the signature.
assert cdemir in [ c for c in onto.individuals_in_signature()]
assert cdemir in [c for c in onto.individuals_in_signature()]
# (10) Save the modified ontology locally.
onto.save(path="babo.owl",rdf_format = "rdfxml")
onto.save(path="babo.owl", rdf_format="rdfxml")


5 changes: 2 additions & 3 deletions examples/ontology_reasoning.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from owlapy.iri import IRI
from owlapy.owl_axiom import OWLSubClassOfAxiom, OWLObjectPropertyDomainAxiom, OWLEquivalentObjectPropertiesAxiom
from owlapy.owl_individual import OWLNamedIndividual
from owlapy.owl_ontology_manager import OntologyManager
from owlapy.owl_ontology import Ontology
from owlapy.owl_property import OWLDataProperty, OWLObjectProperty
from owlapy.owl_reasoner import StructuralReasoner

Expand Down Expand Up @@ -116,8 +116,7 @@
JK = OWLObjectIntersectionOf([J, K])
r1T = OWLObjectSomeValuesFrom(property=r1, filler=OWLClass(IRI('http://www.w3.org/2002/07/owl#', 'Thing')))

manager = OntologyManager()
onto = manager.load_ontology(IRI.create('file://' + data_file))
onto = Ontology(IRI.create('file://' + data_file))

onto.add_axiom(OWLEquivalentObjectPropertiesAxiom([r6, r5]))
onto.add_axiom(OWLEquivalentObjectPropertiesAxiom([r5, r6]))
Expand Down
8 changes: 4 additions & 4 deletions examples/ontology_reasoning_retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
"""
from owlapy.class_expression import OWLClass
from owlapy.owl_axiom import OWLDeclarationAxiom, OWLClassAssertionAxiom, OWLSubClassOfAxiom
from owlapy.owl_ontology_manager import OntologyManager
from owlapy.owl_ontology import Ontology
from owlapy.owl_individual import OWLNamedIndividual
from owlapy.iri import IRI
from owlapy.owl_reasoner import SyncReasoner
# () Define a base IRI.
base_iri = IRI(namespace="https://github.com/dice-group/owlapy#")
# () Create an empty ontology.
onto = OntologyManager().create_ontology(iri=base_iri)
onto = Ontology(base_iri, load=False)
# () Define classes and individuals.
A = OWLClass(iri=base_iri.get_namespace() + "A")
B = OWLClass(iri=base_iri.get_namespace() + "B")
Expand All @@ -35,5 +35,5 @@
reasoner = SyncReasoner(ontology="new_ontology.owl", reasoner="Pellet")
# () Infer instances.
for i in reasoner.ontology.classes_in_signature():
print(f"Retrieve {i}:",end=" ")
print(" ".join( [_.str for _ in reasoner.instances(i)]))
print(f"Retrieve {i}:", end=" ")
print(" ".join([_.str for _ in reasoner.instances(i)]))
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from owlapy.class_expression import (OWLClass, OWLObjectSomeValuesFrom, OWLObjectAllValuesFrom,
OWLObjectIntersectionOf, OWLObjectUnionOf)
from owlapy.owl_ontology_manager import OntologyManager
from owlapy.owl_ontology import Ontology
from owlapy.owl_reasoner import SyncReasoner
from owlapy.utils import concept_reducer_properties, concept_reducer
from owlapy import owl_expression_to_dl
Expand All @@ -12,6 +12,7 @@
import numpy as np
from tqdm import tqdm


def eval_reasoners(iter_owl_exp, mapping,info:str=""):
results = dict()
runtime_results = dict()
Expand Down Expand Up @@ -85,7 +86,7 @@ def plot_similarity_btw_reasoners(results):
owl_reasoners["Pellet"] = SyncReasoner(ontology=ontology_path, reasoner="Pellet")
owl_reasoners["JFact"] = SyncReasoner(ontology=ontology_path, reasoner="JFact")
owl_reasoners["Openllet"] = SyncReasoner(ontology=ontology_path, reasoner="Openllet")
onto = OntologyManager().load_ontology(ontology_path)
onto = Ontology(ontology_path)
c: OWLClass
# () C: OWL Class.
c = {i for i in onto.classes_in_signature()}
Expand Down
6 changes: 2 additions & 4 deletions owlapy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
from .render import owl_expression_to_dl, owl_expression_to_manchester
from .parser import dl_to_owl_expression , manchester_to_owl_expression
from .converter import owl_expression_to_sparql, owl_expression_to_sparql_with_confusion_matrix
from .owl_ontology_manager import OntologyManager

__version__ = '1.4.0'

__all__ = [
'owl_expression_to_dl', 'owl_expression_to_manchester',
'dl_to_owl_expression', 'manchester_to_owl_expression',
'owl_expression_to_sparql', 'owl_expression_to_sparql_with_confusion_matrix',
'OntologyManager'
]
'owl_expression_to_sparql', 'owl_expression_to_sparql_with_confusion_matrix'
]
5 changes: 0 additions & 5 deletions owlapy/abstracts/abstract_owl_ontology.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,6 @@ def object_property_range_axioms(self, property: OWLObjectProperty) -> Iterable[
"""
pass

@abstractmethod
def get_owl_ontology_manager(self) -> _M:
"""Gets the manager that manages this ontology."""
pass

@abstractmethod
def get_ontology_id(self) -> _OI:
"""Gets the OWLOntologyID belonging to this object.
Expand Down
Loading

0 comments on commit 729c4fc

Please sign in to comment.