-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* HermiT is deafault reasoner. Ontoconvert used to accept only FaCT++ because owlready2.reasoning._apply_reasoning_results() was broken. It added the inferred rdfs:subClassOf relations as rdf:type relations. * Moved tests for reasoner into separate file. Created new tests for all three reasoners. which check that the new relation is inferred. * Added new ontology to test reasoning
- Loading branch information
1 parent
acc7b5d
commit c50115b
Showing
8 changed files
with
316 additions
and
127 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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
from typing import TYPE_CHECKING | ||
import pytest | ||
|
||
if TYPE_CHECKING: | ||
from pathlib import Path | ||
|
||
from ontopy.ontology import Ontology | ||
|
||
|
||
def test_sync_reasoner_hermit(repo_dir: "Path") -> None: | ||
"""Test `ontopy:Ontology.sync_reasoner()` with HermiT.""" | ||
from ontopy import get_ontology | ||
|
||
testonto = get_ontology( | ||
repo_dir / "tests" / "testonto" / "testonto_for_reasoner.ttl" | ||
).load() | ||
assert testonto.Avocado | ||
assert not isinstance(testonto.Avocado, testonto.NaturalDye) | ||
testonto.sync_reasoner(reasoner="HermiT") | ||
assert isinstance(testonto.Avocado, testonto.NaturalDye) | ||
|
||
|
||
def test_sync_reasoner_pellet(repo_dir: "Path") -> None: | ||
"""Test `ontopy:Ontology.sync_reasoner()` with Pellet""" | ||
from ontopy import get_ontology | ||
|
||
testonto = get_ontology( | ||
repo_dir / "tests" / "testonto" / "testonto_for_reasoner.ttl" | ||
).load() | ||
|
||
assert testonto.Avocado | ||
assert not isinstance(testonto.Avocado, testonto.NaturalDye) | ||
testonto.sync_reasoner(reasoner="Pellet") | ||
assert isinstance(testonto.Avocado, testonto.NaturalDye) | ||
|
||
|
||
def test_sync_reasoner_fact(repo_dir: "Path") -> None: | ||
"""Test `ontopy:Ontology.sync_reasoner()` with FaCT++""" | ||
from ontopy import get_ontology | ||
|
||
testonto = get_ontology( | ||
repo_dir / "tests" / "testonto" / "testonto_for_reasoner.ttl" | ||
).load() | ||
assert testonto.Avocado | ||
assert not isinstance(testonto.Avocado, testonto.NaturalDye) | ||
testonto.sync_reasoner(reasoner="FaCT++") | ||
assert isinstance(testonto.Avocado, testonto.NaturalDye) | ||
|
||
|
||
def test_sync_reasoner_wrong(testonto: "Ontology") -> None: | ||
"""Test `ontopy:Ontology.sync_reasoner()` with wrong reasoner.""" | ||
with pytest.raises(ValueError) as excinfo: | ||
testonto.sync_reasoner(reasoner="NonExistingReasoner") | ||
assert str(excinfo.value) == ( | ||
"Unknown reasoner 'NonExistingReasoner'. " | ||
"Supported reasoners are 'Pellet', 'HermiT' and 'FaCT++'." | ||
) |
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 |
---|---|---|
@@ -0,0 +1,125 @@ | ||
@prefix : <http://emmo.info/testontology#> . | ||
@prefix owl: <http://www.w3.org/2002/07/owl#> . | ||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . | ||
@prefix xml: <http://www.w3.org/XML/1998/namespace> . | ||
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . | ||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . | ||
@prefix skos: <http://www.w3.org/2004/02/skos/core#> . | ||
@base <http://emmo.info/testontology> . | ||
|
||
<http://emmo.info/testontology> rdf:type owl:Ontology ; | ||
owl:versionIRI <http://emmo.info/testonto/0.1.0/testontology> . | ||
|
||
################################################################# | ||
# Annotation properties | ||
################################################################# | ||
|
||
### http://www.w3.org/2004/02/skos/core#altLabel | ||
skos:altLabel rdf:type owl:AnnotationProperty . | ||
|
||
|
||
### http://www.w3.org/2004/02/skos/core#prefLabel | ||
skos:prefLabel rdf:type owl:AnnotationProperty . | ||
|
||
|
||
################################################################# | ||
# Object Properties | ||
################################################################# | ||
|
||
### http://emmo.info/testontology#hasColour | ||
:hasColour rdf:type owl:ObjectProperty ; | ||
rdfs:domain :Dye ; | ||
rdfs:range :Colour . | ||
|
||
|
||
### http://emmo.info/testontology#hasNaturePart | ||
:hasNaturePart rdf:type owl:ObjectProperty ; | ||
rdfs:subPropertyOf :hasPart ; | ||
rdfs:domain :Nature ; | ||
rdfs:range :Nature . | ||
|
||
|
||
### http://emmo.info/testontology#hasPart | ||
:hasPart rdf:type owl:ObjectProperty . | ||
|
||
|
||
################################################################# | ||
# Classes | ||
################################################################# | ||
|
||
### http://emmo.info/testontology#Avocado | ||
:Avocado rdf:type owl:Class ; | ||
rdfs:subClassOf :EvergreenTree , | ||
[ rdf:type owl:Restriction ; | ||
owl:onProperty :hasColour ; | ||
owl:qualifiedCardinality "1"^^xsd:nonNegativeInteger ; | ||
owl:onClass :Colour | ||
] ; | ||
skos:prefLabel "Avocado"@en . | ||
|
||
|
||
### http://emmo.info/testontology#Colour | ||
:Colour rdf:type owl:Class . | ||
|
||
|
||
### http://emmo.info/testontology#DesiduousTree | ||
:DesiduousTree rdf:type owl:Class ; | ||
rdfs:subClassOf :Tree ; | ||
skos:prefLabel "DesiduousTree"@en . | ||
|
||
|
||
### http://emmo.info/testontology#Dye | ||
:Dye rdf:type owl:Class . | ||
|
||
|
||
### http://emmo.info/testontology#EngelmannSpruce | ||
:EngelmannSpruce rdf:type owl:Class ; | ||
rdfs:subClassOf :Spruce ; | ||
skos:prefLabel "EngelmannSpruce"@en . | ||
|
||
|
||
### http://emmo.info/testontology#EvergreenTree | ||
:EvergreenTree rdf:type owl:Class ; | ||
rdfs:subClassOf :Tree ; | ||
skos:prefLabel "EvergreenTree"@en . | ||
|
||
|
||
### http://emmo.info/testontology#NaturalDye | ||
:NaturalDye rdf:type owl:Class ; | ||
owl:equivalentClass [ owl:intersectionOf ( :Dye | ||
:Nature | ||
) ; | ||
rdf:type owl:Class | ||
] ; | ||
skos:prefLabel "NaturalDye"@en . | ||
|
||
|
||
### http://emmo.info/testontology#Nature | ||
:Nature rdf:type owl:Class . | ||
|
||
|
||
### http://emmo.info/testontology#NorwaySpruce | ||
:NorwaySpruce rdf:type owl:Class ; | ||
rdfs:subClassOf :Spruce ; | ||
skos:prefLabel "NorwaySpruce"@en . | ||
|
||
|
||
### http://emmo.info/testontology#ShingledHedgehogMushroom | ||
:ShingledHedgehogMushroom rdf:type owl:Class ; | ||
rdfs:subClassOf :NaturalDye ; | ||
skos:prefLabel "ShingledHedgehogMushroom"@en . | ||
|
||
|
||
### http://emmo.info/testontology#Spruce | ||
:Spruce rdf:type owl:Class ; | ||
rdfs:subClassOf :EvergreenTree ; | ||
skos:prefLabel "Spruce"@en . | ||
|
||
|
||
### http://emmo.info/testontology#Tree | ||
:Tree rdf:type owl:Class ; | ||
rdfs:subClassOf :Nature ; | ||
skos:prefLabel "Tree"@en . | ||
|
||
|
||
### Generated by the OWL API (version 4.5.9.2019-02-01T07:24:44Z) https://github.com/owlcs/owlapi |
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,105 @@ | ||
@prefix : <http://emmo.info/testonto/0.1.0/testontology#> . | ||
@prefix owl: <http://www.w3.org/2002/07/owl#> . | ||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . | ||
@prefix xml: <http://www.w3.org/XML/1998/namespace> . | ||
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . | ||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . | ||
@base <http://emmo.info/testonto/0.1.0/testontology> . | ||
|
||
<http://emmo.info/testonto/0.1.0/testontology> rdf:type owl:Ontology . | ||
|
||
################################################################# | ||
# Object Properties | ||
################################################################# | ||
|
||
### http://emmo.info/testontology#hasColour | ||
<http://emmo.info/testontology#hasColour> rdf:type owl:ObjectProperty ; | ||
rdfs:domain <http://emmo.info/testontology#Dye> ; | ||
rdfs:range <http://emmo.info/testontology#Colour> . | ||
|
||
|
||
### http://emmo.info/testontology#hasNaturePart | ||
<http://emmo.info/testontology#hasNaturePart> rdf:type owl:ObjectProperty ; | ||
rdfs:subPropertyOf <http://emmo.info/testontology#hasPart> ; | ||
rdfs:domain <http://emmo.info/testontology#Nature> ; | ||
rdfs:range <http://emmo.info/testontology#Nature> . | ||
|
||
|
||
### http://emmo.info/testontology#hasPart | ||
<http://emmo.info/testontology#hasPart> rdf:type owl:ObjectProperty . | ||
|
||
|
||
################################################################# | ||
# Classes | ||
################################################################# | ||
|
||
### http://emmo.info/testontology#Avocado | ||
<http://emmo.info/testontology#Avocado> rdf:type owl:Class ; | ||
rdfs:subClassOf <http://emmo.info/testontology#EvergreenTree> , | ||
<http://emmo.info/testontology#NaturalDye> , | ||
[ rdf:type owl:Restriction ; | ||
owl:onProperty <http://emmo.info/testontology#hasColour> ; | ||
owl:qualifiedCardinality "1"^^xsd:nonNegativeInteger ; | ||
owl:onClass <http://emmo.info/testontology#Colour> | ||
] . | ||
|
||
|
||
### http://emmo.info/testontology#Colour | ||
<http://emmo.info/testontology#Colour> rdf:type owl:Class . | ||
|
||
|
||
### http://emmo.info/testontology#DesiduousTree | ||
<http://emmo.info/testontology#DesiduousTree> rdf:type owl:Class ; | ||
rdfs:subClassOf <http://emmo.info/testontology#Tree> . | ||
|
||
|
||
### http://emmo.info/testontology#Dye | ||
<http://emmo.info/testontology#Dye> rdf:type owl:Class . | ||
|
||
|
||
### http://emmo.info/testontology#EngelmannSpruce | ||
<http://emmo.info/testontology#EngelmannSpruce> rdf:type owl:Class ; | ||
rdfs:subClassOf <http://emmo.info/testontology#Spruce> . | ||
|
||
|
||
### http://emmo.info/testontology#EvergreenTree | ||
<http://emmo.info/testontology#EvergreenTree> rdf:type owl:Class ; | ||
rdfs:subClassOf <http://emmo.info/testontology#Tree> . | ||
|
||
|
||
### http://emmo.info/testontology#NaturalDye | ||
<http://emmo.info/testontology#NaturalDye> rdf:type owl:Class ; | ||
owl:equivalentClass [ owl:intersectionOf ( <http://emmo.info/testontology#Dye> | ||
<http://emmo.info/testontology#Nature> | ||
) ; | ||
rdf:type owl:Class | ||
] ; | ||
rdfs:subClassOf <http://emmo.info/testontology#Dye> , | ||
<http://emmo.info/testontology#Nature> . | ||
|
||
|
||
### http://emmo.info/testontology#Nature | ||
<http://emmo.info/testontology#Nature> rdf:type owl:Class . | ||
|
||
|
||
### http://emmo.info/testontology#NorwaySpruce | ||
<http://emmo.info/testontology#NorwaySpruce> rdf:type owl:Class ; | ||
rdfs:subClassOf <http://emmo.info/testontology#Spruce> . | ||
|
||
|
||
### http://emmo.info/testontology#ShingledHedgehogMushroom | ||
<http://emmo.info/testontology#ShingledHedgehogMushroom> rdf:type owl:Class ; | ||
rdfs:subClassOf <http://emmo.info/testontology#NaturalDye> . | ||
|
||
|
||
### http://emmo.info/testontology#Spruce | ||
<http://emmo.info/testontology#Spruce> rdf:type owl:Class ; | ||
rdfs:subClassOf <http://emmo.info/testontology#EvergreenTree> . | ||
|
||
|
||
### http://emmo.info/testontology#Tree | ||
<http://emmo.info/testontology#Tree> rdf:type owl:Class ; | ||
rdfs:subClassOf <http://emmo.info/testontology#Nature> . | ||
|
||
|
||
### Generated by the OWL API (version 4.5.9.2019-02-01T07:24:44Z) https://github.com/owlcs/owlapi |
Oops, something went wrong.