diff --git a/README.md b/README.md index d121e51..56c1d08 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ pip3 install owlapy ```shell # To download RDF knowledge graphs wget https://files.dice-research.org/projects/Ontolearn/KGs.zip -O ./KGs.zip && unzip KGs.zip -pytest -p no:warnings -x # Running 103 tests takes ~ 30 mins +pytest -p no:warnings -x # Running 102 tests takes ~ 1 min ``` ## Usage diff --git a/tests/test_owlapi_adaptor.py b/tests/test_owlapi_adaptor.py index 47d5e9a..5f6c197 100644 --- a/tests/test_owlapi_adaptor.py +++ b/tests/test_owlapi_adaptor.py @@ -12,6 +12,10 @@ from owlapy.owlapi_adaptor import OWLAPIAdaptor from owlapy.providers import owl_datatype_min_inclusive_restriction +from owlapy.class_expression import OWLClassExpression +from owlapy.owl_ontology_manager import OntologyManager +from owlapy.owlapi_adaptor import OWLAPIAdaptor + class TestOwlapiAdaptor(unittest.TestCase): ns = "http://dl-learner.org/mutagenesis#" @@ -22,6 +26,36 @@ class TestOwlapiAdaptor(unittest.TestCase): ce = OWLObjectIntersectionOf([nitrogen38, has_charge_more_than_0_85]) adaptor = OWLAPIAdaptor(ontology_path) + def test_named_concepts(self): + + ontology_path = "KGs/Family/family-benchmark_rich_background.owl" + + # Available OWL Reasoners: 'HermiT', 'Pellet', 'JFact', 'Openllet' + owl_reasoners = dict() + owl_reasoners["HermiT"] = OWLAPIAdaptor(path=ontology_path, name_reasoner="HermiT") + owl_reasoners["Pellet"] = OWLAPIAdaptor(path=ontology_path, name_reasoner="Pellet") + owl_reasoners["JFact"] = OWLAPIAdaptor(path=ontology_path, name_reasoner="JFact") + owl_reasoners["Openllet"] = OWLAPIAdaptor(path=ontology_path, name_reasoner="Openllet") + + onto = OntologyManager().load_ontology(ontology_path) + + def compute_agreements(i: OWLClassExpression, verbose=False): + if verbose: + print(f"Computing agreements between Reasoners on {i}...") + retrieval_result = None + flag = False + for k, reasoner in owl_reasoners.items(): + if retrieval_result: + flag = retrieval_result == {_.str for _ in reasoner.instances(i)} + else: + retrieval_result = {_.str for _ in reasoner.instances(i)} + return flag + # Agreement between instances over + for i in onto.classes_in_signature(): + assert compute_agreements(i, True) + for k, reasoner in owl_reasoners.items(): + reasoner.stopJVM() + def test_consistency_check(self): self.assertEqual(self.adaptor.has_consistent_ontology(), True)