Skip to content

Commit

Permalink
Initial test for alc retrieval on father with hermit started
Browse files Browse the repository at this point in the history
  • Loading branch information
Demirrr committed Sep 18, 2024
1 parent 16789b7 commit 32198ff
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions tests/test_reasoner_alc_father_ontology.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from owlapy.owl_reasoner import SyncReasoner
from owlapy.class_expression import OWLClass, OWLObjectSomeValuesFrom
from owlapy.owl_individual import OWLNamedIndividual
from owlapy.iri import IRI
from owlapy.owl_property import OWLObjectProperty


class TestHermitFather:
def test_readme(self):

ontology_path = "KGs/Family/father.owl"
hermit = SyncReasoner(ontology=ontology_path, reasoner="HermiT")

# Thing
thing = OWLClass(IRI('http://www.w3.org/2002/07/owl#', 'Thing'))
# Person OWL Class
person = eval("OWLClass(IRI('http://example.com/father#', 'person'))")
# Female OWL CLass
female = eval("OWLClass(IRI('http://example.com/father#', 'female'))")
# hasChild object property
hasChild = eval("OWLObjectProperty(IRI('http://example.com/father#', 'hasChild'))")

# Things
assert hermit.instances(thing) == eval(
"{OWLNamedIndividual(IRI('http://example.com/father#', 'anna')), OWLNamedIndividual(IRI('http://example.com/father#', 'martin')), OWLNamedIndividual(IRI('http://example.com/father#', 'heinz')), OWLNamedIndividual(IRI('http://example.com/father#', 'stefan')), OWLNamedIndividual(IRI('http://example.com/father#', 'michelle')), OWLNamedIndividual(IRI('http://example.com/father#', 'markus'))}")

# hasChild a thing.
assert hermit.instances(OWLObjectSomeValuesFrom(property=hasChild, filler=thing)) == eval(
"{OWLNamedIndividual(IRI('http://example.com/father#', 'markus')), OWLNamedIndividual(IRI('http://example.com/father#', 'martin')), OWLNamedIndividual(IRI('http://example.com/father#', 'stefan')), OWLNamedIndividual(IRI('http://example.com/father#', 'anna'))}")

# hasChild a person.
assert hermit.instances(OWLObjectSomeValuesFrom(property=hasChild, filler=person)) == eval(
"{OWLNamedIndividual(IRI('http://example.com/father#', 'markus')), OWLNamedIndividual(IRI('http://example.com/father#', 'martin')), OWLNamedIndividual(IRI('http://example.com/father#', 'stefan')), OWLNamedIndividual(IRI('http://example.com/father#', 'anna'))}")

# hasChild a female.
assert hermit.instances(OWLObjectSomeValuesFrom(property=hasChild, filler=female)) == eval(
"{OWLNamedIndividual(IRI('http://example.com/father#', 'markus'))}")
# Question: hasChild something that hasChild a female.
# Answer: stefan
# (stefan haschild markus) and markus haschild anna
assert hermit.instances(OWLObjectSomeValuesFrom(property=hasChild,
filler=OWLObjectSomeValuesFrom(property=hasChild,
filler=female))) == eval(
"{OWLNamedIndividual(IRI('http://example.com/father#', 'stefan'))}")

0 comments on commit 32198ff

Please sign in to comment.