Skip to content

Commit

Permalink
el concept construct tested via hashing
Browse files Browse the repository at this point in the history
  • Loading branch information
Demirrr committed Nov 8, 2024
1 parent 1bf6604 commit 8678792
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions tests/test_hashing.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
from owlapy.class_expression import OWLClass, OWLObjectIntersectionOf
from owlapy.owl_property import OWLObjectProperty
from owlapy.class_expression import OWLObjectSomeValuesFrom
from owlapy.class_expression import OWLObjectSomeValuesFrom, OWLObjectAllValuesFrom
from owlapy.converter import owl_expression_to_sparql
from owlapy.render import owl_expression_to_dl
from owlapy.iri import IRI
from owlapy.class_expression import OWLObjectUnionOf, OWLObjectIntersectionOf
from owlapy.class_expression import OWLClass, OWLObjectUnionOf, OWLObjectIntersectionOf

class TestHashing:
def test_simple(self):

def test_el_description_logic_hash(self):
"""
EL allows complex concepts of the following form:
C := \top | A | C1 u C2 | \existr.C
where A is a concept and r a role name.
For more, refer to https://www.emse.fr/~zimmermann/Teaching/KRR/el.html
"""
memory = dict()
# An OWL Class can be used as a key in a dictionary.
memory[OWLClass("http://example.com/father#A")] = OWLClass("http://example.com/father#A")
Expand All @@ -22,7 +29,7 @@ def test_simple(self):
# Since the order doesn't matter in an OWLObjectUnionOf the following also holds
assert OWLObjectUnionOf((v, k)) in unions

# An OWLObjectUnionOf over two OWL Classes can be added into a set.
# This also works for intersections.
intersections.add(OWLObjectIntersectionOf((k, v)))
# Since the order doesn't matter in an OWLObjectUnionOf the following also holds
assert OWLObjectIntersectionOf((v, k)) in intersections
Expand All @@ -31,3 +38,16 @@ def test_simple(self):
memory[i]=i
for k, v in memory.items():
assert k == v

atomic_concepts={OWLClass("http://example.com/father#A"),OWLClass("http://example.com/father#B")}
properties={OWLObjectProperty("http://example.com/society#hasChild")}
memory = dict()
for ac in atomic_concepts:
for op in properties:
# OWLObjectSomeValuesFrom can be used as a key.
memory[OWLObjectSomeValuesFrom(property=op, filler=ac)] = OWLObjectSomeValuesFrom(property=op, filler=ac)
# TODO: https://github.com/dice-group/owlapy/issues/103
# memory[OWLObjectAllValuesFrom(property=op, filler=ac)] = OWLObjectAllValuesFrom(property=op, filler=ac)

for k, v in memory.items():
assert k == v

0 comments on commit 8678792

Please sign in to comment.