Skip to content

Commit

Permalink
Agrement over named concept added
Browse files Browse the repository at this point in the history
  • Loading branch information
Demirrr committed Aug 29, 2024
1 parent e83232b commit 8a0210d
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/test_owlapi_adaptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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#"
Expand All @@ -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)

Expand Down

0 comments on commit 8a0210d

Please sign in to comment.