-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated test/examples using SyncReasoner
- Loading branch information
Showing
3 changed files
with
27 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,34 @@ | ||
from owlapy.owlapi_adaptor import OWLAPIAdaptor | ||
from owlapy.owl_reasoner import SyncReasoner | ||
from owlapy.iri import IRI | ||
from owlapy.class_expression import OWLClass, OWLObjectIntersectionOf | ||
from owlapy.static_funcs import stopJVM | ||
|
||
ontology_location = "../KGs/Family/family-benchmark_rich_background.owl" | ||
|
||
# Start an adaptor session and perform your operations. | ||
adaptor = OWLAPIAdaptor(ontology_location, "HermiT") | ||
# Create an SyncReasoner | ||
reasoner = SyncReasoner(ontology_location, "HermiT") | ||
# Check ontology consistency | ||
print(f"Is the given ontology consistent? --> {adaptor.has_consistent_ontology()}") | ||
print(f"Is the given ontology consistent? --> {reasoner.has_consistent_ontology()}") | ||
|
||
# Construct an owlapy class expression | ||
brother = OWLClass(IRI.create("http://www.benchmark.org/family#Brother")) | ||
father = OWLClass(IRI.create("http://www.benchmark.org/family#Father")) | ||
brother_and_father = OWLObjectIntersectionOf([brother, father]) | ||
|
||
# Find individual belonging to that class expression | ||
instances = adaptor.instances(brother_and_father) | ||
instances = reasoner.instances(brother_and_father) | ||
print("----------------------") | ||
print("Individuals that are brother and father at the same time:") | ||
[print(_) for _ in instances] | ||
|
||
# Map the class expression from owlapy to owlapi | ||
py_to_pi = adaptor.mapper.map_(brother_and_father) | ||
py_to_pi = reasoner.mapper.map_(brother_and_father) | ||
|
||
# Map the class expression from owlapi to owlapy | ||
pi_to_py = adaptor.mapper.map_(py_to_pi) | ||
pi_to_py = reasoner.mapper.map_(py_to_pi) | ||
print("----------------------") | ||
print(f"Owlapy ce: {pi_to_py}") | ||
|
||
# Stop the JVM to free the associated resources. | ||
adaptor.stopJVM() # or jpype.shutdownJVM() | ||
stopJVM() # or jpype.shutdownJVM() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters