-
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.
Merge remote-tracking branch 'origin/develop' into new_terminal_command
- Loading branch information
Showing
12 changed files
with
116 additions
and
61 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
""" | ||
KB = { (A subclass B), (B subclass C), (x type A) } | ||
KB = { (A subclass B), (B subclass C), (x type A), (x type B), (x type C) } | ||
Missing types are inferred due to subclass hierarchy. | ||
""" | ||
from owlapy.class_expression import OWLClass | ||
from owlapy.owl_axiom import OWLDeclarationAxiom, OWLClassAssertionAxiom, OWLSubClassOfAxiom | ||
from owlapy.owl_ontology_manager import OntologyManager | ||
from owlapy.owl_individual import OWLNamedIndividual | ||
from owlapy.iri import IRI | ||
from owlapy.owl_reasoner import SyncReasoner | ||
# () Define a base IRI. | ||
base_iri = IRI(namespace="https://github.com/dice-group/owlapy#") | ||
# () Create an empty ontology. | ||
onto = OntologyManager().create_ontology(iri=base_iri) | ||
# () Define classes and individuals. | ||
A = OWLClass(iri=base_iri.get_namespace() + "A") | ||
B = OWLClass(iri=base_iri.get_namespace() + "B") | ||
C = OWLClass(iri=base_iri.get_namespace() + "C") | ||
x = OWLNamedIndividual(iri=base_iri.get_namespace() + "x") | ||
# () Add axioms. | ||
onto.add_axiom([OWLDeclarationAxiom(A), | ||
OWLDeclarationAxiom(B), | ||
OWLDeclarationAxiom(C), | ||
OWLDeclarationAxiom(x), | ||
OWLSubClassOfAxiom(A,B), | ||
OWLSubClassOfAxiom(B,C), | ||
OWLClassAssertionAxiom(x,A)]) | ||
# () Save axioms [ (A subclass B), (B subclass C), (x type A) ]. | ||
onto.save("new_ontology.owl") | ||
# () Initialize reasoner. | ||
reasoner = SyncReasoner(ontology="new_ontology.owl", reasoner="Pellet") | ||
# () Infer instances. | ||
for i in reasoner.ontology.classes_in_signature(): | ||
print(f"Retrieve {i}:",end=" ") | ||
print(" ".join( [_.str for _ in reasoner.instances(i)])) |
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from owlapy.owl_reasoner import SyncReasoner | ||
from owlapy import OntologyManager | ||
from owlapy.class_expression import OWLClassExpression | ||
from typing import Dict | ||
ontology_path = "../KGs/Family/family-benchmark_rich_background.owl" | ||
# () Load ontology | ||
onto = OntologyManager().load_ontology(ontology_path) | ||
|
||
# () Initialize Reasoners | ||
reasoners = dict() | ||
reasoners["HermiT"] = SyncReasoner(ontology=ontology_path, reasoner="HermiT") | ||
reasoners["Pellet"] = SyncReasoner(ontology=ontology_path, reasoner="Pellet") | ||
reasoners["JFact"] = SyncReasoner(ontology=ontology_path, reasoner="JFact") | ||
reasoners["Openllet"] = SyncReasoner(ontology=ontology_path, reasoner="Openllet") | ||
|
||
def compute_agreements(owl_reasoners:Dict[str,SyncReasoner], expression: OWLClassExpression, verbose=False): | ||
if verbose: | ||
print(f"Computing agreements between Reasoners on {expression}...",end="\t") | ||
retrieval_result = None | ||
flag = False | ||
for __, reasoner in owl_reasoners.items(): | ||
if retrieval_result: | ||
flag = retrieval_result == {_.str for _ in reasoner.instances(expression)} | ||
else: | ||
retrieval_result = {_.str for _ in reasoner.instances(expression)} | ||
if verbose: | ||
print(f"Successful:{flag}") | ||
return flag | ||
|
||
# () Iterate over named classes | ||
for c in onto.classes_in_signature(): | ||
# reasoners must agree | ||
assert compute_agreements(reasoners, c, True) |
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
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
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
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 |
---|---|---|
|
@@ -8,9 +8,7 @@ | |
version="1.3.0", | ||
packages=find_packages(), | ||
include_package_data=True, | ||
package_data={ | ||
'owlapy': ['jar_dependencies/*.jar'], | ||
}, | ||
package_data={'owlapy': ['jar_dependencies/*.jar'],}, | ||
install_requires=[ | ||
"pandas>=1.5.0", | ||
"requests>=2.32.3", | ||
|
@@ -19,7 +17,8 @@ | |
"pytest>=8.1.1", | ||
"sortedcontainers>=2.4.0", | ||
"owlready2>=0.40", | ||
"JPype1>=1.5.0"], | ||
"JPype1>=1.5.0", | ||
"tqdm>=4.66.5"], | ||
author='Caglar Demir', | ||
author_email='[email protected]', | ||
url='https://github.com/dice-group/owlapy', | ||
|