Skip to content

Commit a8c758f

Browse files
authored
Merge pull request #49 from dice-group/owlapi_adaptor
Refactoring owlapi adaptor
2 parents 9762fbc + 227c6b9 commit a8c758f

File tree

62 files changed

+181
-122
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+181
-122
lines changed

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
project = 'OWLAPY'
1515
author = 'Ontolearn Team'
16-
release = '0.1.2'
16+
release = '1.1.1'
1717

1818
# -- General configuration ---------------------------------------------------
1919
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

docs/usage/main.md

Lines changed: 1 addition & 1 deletion

docs/usage/owlapi_adaptor.md

Lines changed: 16 additions & 10 deletions
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from owlapy.owl_property import OWLObjectProperty
2+
from owlapy.owlapi_adaptor import OWLAPIAdaptor
3+
from owlapy.iri import IRI
4+
from owlapy.class_expression import OWLClass, OWLObjectIntersectionOf, OWLObjectAllValuesFrom, OWLObjectComplementOf
5+
from owlapy.providers import owl_datatype_min_exclusive_restriction
6+
import time
7+
ontology_location = "../KGs/Carcinogenesis/carcinogenesis.owl"
8+
9+
i1 = set()
10+
i2 = set()
11+
i3 = set()
12+
i4 = set()
13+
14+
for reasoner in ["HermiT", "Pellet", "JFact", "Openllet"]:
15+
adaptor = OWLAPIAdaptor(ontology_location, reasoner)
16+
17+
ce = OWLObjectAllValuesFrom(property=OWLObjectProperty(IRI('http://dl-learner.org/carcinogenesis#','hasAtom')),
18+
filler=OWLObjectComplementOf(OWLClass(IRI('http://dl-learner.org/carcinogenesis#',
19+
'Sulfur-75'))))
20+
21+
if reasoner == "HermiT":
22+
i1 = set(adaptor.instances(ce))
23+
elif reasoner == "Pellet":
24+
i2 = set(adaptor.instances(ce))
25+
elif reasoner == "JFact":
26+
i3 = set(adaptor.instances(ce))
27+
elif reasoner == "Openllet":
28+
i4 = set(adaptor.instances(ce))
29+
30+
print("Hermit-Pellet:")
31+
[print(_) for _ in i1-i2]
32+
time.sleep(10)
33+
print("Hermit-JFact:")
34+
[print(_) for _ in i1-i3]
35+
time.sleep(10)
36+
print("Hermit-Openllet:")
37+
[print(_) for _ in i1-i4]
38+
time.sleep(10)
39+
print("Pellet-JFact:")
40+
[print(_) for _ in i2-i3]
41+
time.sleep(10)
42+
print("Pellet-Openllet:")
43+
[print(_) for _ in i2-i4]
44+
time.sleep(10)
45+
print("JFact-Openllet:")
46+
[print(_) for _ in i3-i4]

examples/using_owlapi_adaptor.py

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,29 @@
55
ontology_location = "../KGs/Family/family-benchmark_rich_background.owl"
66

77
# Start an adaptor session and perform your operations.
8-
with OWLAPIAdaptor(ontology_location) as adaptor:
9-
# Check ontology consistency using HermiT
10-
print(f"Is the given ontology consistent? --> {adaptor.has_consistent_ontology()}")
11-
12-
# Construct an owlapy class expression
13-
brother = OWLClass(IRI.create("http://www.benchmark.org/family#Brother"))
14-
father = OWLClass(IRI.create("http://www.benchmark.org/family#Father"))
15-
brother_and_father = OWLObjectIntersectionOf([brother, father])
16-
17-
# Find individual belonging to that class expression (using HermiT behind the scene)
18-
instances = adaptor.instances(brother_and_father)
19-
print("----------------------")
20-
print("Individuals that are brother and father at the same time:")
21-
[print(_) for _ in instances]
22-
23-
# Convert from owlapy to owlapi
24-
py_to_pi = adaptor.convert_to_owlapi(brother_and_father)
25-
26-
# Convert from owlapi to owlapy
27-
pi_to_py = adaptor.convert_from_owlapi(py_to_pi, "http://www.benchmark.org/family#")
28-
print("----------------------")
29-
print(f"Owlapy ce: {pi_to_py}")
8+
adaptor = OWLAPIAdaptor(ontology_location, "HermiT")
9+
# Check ontology consistency
10+
print(f"Is the given ontology consistent? --> {adaptor.has_consistent_ontology()}")
11+
12+
# Construct an owlapy class expression
13+
brother = OWLClass(IRI.create("http://www.benchmark.org/family#Brother"))
14+
father = OWLClass(IRI.create("http://www.benchmark.org/family#Father"))
15+
brother_and_father = OWLObjectIntersectionOf([brother, father])
16+
17+
# Find individual belonging to that class expression
18+
instances = adaptor.instances(brother_and_father)
19+
print("----------------------")
20+
print("Individuals that are brother and father at the same time:")
21+
[print(_) for _ in instances]
22+
23+
# Convert from owlapy to owlapi
24+
py_to_pi = adaptor.convert_to_owlapi(brother_and_father)
25+
26+
# Convert from owlapi to owlapy
27+
pi_to_py = adaptor.convert_from_owlapi(py_to_pi, "http://www.benchmark.org/family#")
28+
print("----------------------")
29+
print(f"Owlapy ce: {pi_to_py}")
30+
31+
# Stop the JVM to free the associated resources.
32+
adaptor.stopJVM() # or jpype.shutdownJVM()
3033

owlapy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from .render import owl_expression_to_dl, owl_expression_to_manchester
22
from .parser import dl_to_owl_expression, manchester_to_owl_expression
33
from .converter import owl_expression_to_sparql
4-
__version__ = '1.1.0'
4+
__version__ = '1.1.1'
220 KB
Binary file not shown.

jar_dependencies/animal-sniffer-annotations-1.14.jar renamed to owlapy/jar_dependencies/animal-sniffer-annotations-1.14.jar

File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)