OWLAPI:HermiT reasoner thows "UnsupportedDatatypeException" 来自导入的数据类型 Ontology
OWLAPI : HermiT reasoner thows "UnsupportedDatatypeException" for data type from imported Ontology
我有 2 个本体(通过 Protege 生成)。
A ontology (A.owl) :-
<?xml version="1.0"?>
<!DOCTYPE rdf:RDF [
<!ENTITY owl "http://www.w3.org/2002/07/owl#" >
<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
]>
<rdf:RDF xmlns="http://www.semanticweb.org/ontologies/A#"
xml:base="http://www.semanticweb.org/ontologies/A"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<owl:Ontology rdf:about="http://www.semanticweb.org/ontologies/A">
<owl:imports rdf:resource="http://www.semanticweb.org/ontologies/Z"/>
</owl:Ontology>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Classes
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/ontologies/A#A -->
<owl:Class rdf:about="http://www.semanticweb.org/ontologies/A#A">
<rdfs:subClassOf rdf:resource="http://www.semanticweb.org/ontologies/A#B"/>
</owl:Class>
<!-- http://www.semanticweb.org/ontologies/A#B -->
<owl:Class rdf:about="http://www.semanticweb.org/ontologies/A#B"/>
</rdf:RDF>
<!-- Generated by the OWL API (version 3.5.1) http://owlapi.sourceforge.net -->
Z ontology (Z.owl) :-
<?xml version="1.0"?>
<!DOCTYPE rdf:RDF [
<!ENTITY owl "http://www.w3.org/2002/07/owl#" >
<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
]>
<rdf:RDF xmlns="http://www.semanticweb.org/ontologies/Z#"
xml:base="http://www.semanticweb.org/ontologies/Z"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<owl:Ontology rdf:about="http://www.semanticweb.org/ontologies/Z"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Datatypes
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/ontologies/Z#myName -->
<rdfs:Datatype rdf:about="http://www.semanticweb.org/ontologies/Z#myName"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Object Properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/ontologies/Z#myProp -->
<owl:ObjectProperty rdf:about="http://www.semanticweb.org/ontologies/Z#myProp"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Data properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/ontologies/Z#name -->
<owl:DatatypeProperty rdf:about="http://www.semanticweb.org/ontologies/Z#name">
<rdfs:range rdf:resource="http://www.semanticweb.org/ontologies/Z#myName"/>
</owl:DatatypeProperty>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Classes
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/ontologies/Z#X -->
<owl:Class rdf:about="http://www.semanticweb.org/ontologies/Z#X">
<rdfs:subClassOf rdf:resource="http://www.semanticweb.org/ontologies/Z#Y"/>
</owl:Class>
<!-- http://www.semanticweb.org/ontologies/Z#Y -->
<owl:Class rdf:about="http://www.semanticweb.org/ontologies/Z#Y"/>
</rdf:RDF>
<!-- Generated by the OWL API (version 3.5.1) http://owlapi.sourceforge.net -->
我在 A.owl
中导入了 Z.owl
。当我 运行 HermiT reasoner 和 A ontology 时。它抛出 org.semanticweb.HermiT.datatypes.UnsupportedDatatypeException
异常。
异常详情:-
Exception in thread "main" org.semanticweb.HermiT.datatypes.UnsupportedDatatypeException: HermiT supports all and only the datatypes of the OWL 2 datatype map, see
http://www.w3.org/TR/owl2-syntax/#Datatype_Maps.
The datatype 'http://www.semanticweb.org/ontologies/Z#myName' is not part of the OWL 2 datatype map and
no custom datatype definition is given;
therefore, HermiT cannot handle this datatype.
我的 JAVA 代码是:-
Configuration reasonerConf = new Configuration();
reasonerConf.throwInconsistentOntologyException = false;
ReasonerFactory factory = new ReasonerFactory();
OWLReasoner reasoner = factory.createReasoner(owlOntology, reasonerConf); //Line where it throws above Exception
owlOntology
是当前工作的 ontology,它是 'A' 加载到 owlManager
(OWLOntologyManager) 中。 'Z' ontology也在这个owlManager
.
我尝试 运行 HermiT 推理机,但它没有抛出任何异常。
您声明了一个数据类型:
<rdfs:Datatype rdf:about="http://www.semanticweb.org/ontologies/Z#myName"/>
但它没有关联的定义。它的词汇形式是什么? "foo"^^ex:myName 是否合法?它是否等同于 "FOO"^^ex:myName 的值? HermiT 没有办法知道这些问题的答案,因此抱怨:
The datatype 'http://www.semanticweb.org/ontologies/Z#myName' is not part of the OWL 2 datatype map and no custom datatype definition is given; therefore, HermiT cannot handle this datatype.
您需要为此数据类型提供某种 HermiT 可以理解的定义,或者可能改用数据类型分面。
我有 2 个本体(通过 Protege 生成)。
A ontology (A.owl) :-
<?xml version="1.0"?>
<!DOCTYPE rdf:RDF [
<!ENTITY owl "http://www.w3.org/2002/07/owl#" >
<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
]>
<rdf:RDF xmlns="http://www.semanticweb.org/ontologies/A#"
xml:base="http://www.semanticweb.org/ontologies/A"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<owl:Ontology rdf:about="http://www.semanticweb.org/ontologies/A">
<owl:imports rdf:resource="http://www.semanticweb.org/ontologies/Z"/>
</owl:Ontology>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Classes
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/ontologies/A#A -->
<owl:Class rdf:about="http://www.semanticweb.org/ontologies/A#A">
<rdfs:subClassOf rdf:resource="http://www.semanticweb.org/ontologies/A#B"/>
</owl:Class>
<!-- http://www.semanticweb.org/ontologies/A#B -->
<owl:Class rdf:about="http://www.semanticweb.org/ontologies/A#B"/>
</rdf:RDF>
<!-- Generated by the OWL API (version 3.5.1) http://owlapi.sourceforge.net -->
Z ontology (Z.owl) :-
<?xml version="1.0"?>
<!DOCTYPE rdf:RDF [
<!ENTITY owl "http://www.w3.org/2002/07/owl#" >
<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
]>
<rdf:RDF xmlns="http://www.semanticweb.org/ontologies/Z#"
xml:base="http://www.semanticweb.org/ontologies/Z"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<owl:Ontology rdf:about="http://www.semanticweb.org/ontologies/Z"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Datatypes
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/ontologies/Z#myName -->
<rdfs:Datatype rdf:about="http://www.semanticweb.org/ontologies/Z#myName"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Object Properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/ontologies/Z#myProp -->
<owl:ObjectProperty rdf:about="http://www.semanticweb.org/ontologies/Z#myProp"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Data properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/ontologies/Z#name -->
<owl:DatatypeProperty rdf:about="http://www.semanticweb.org/ontologies/Z#name">
<rdfs:range rdf:resource="http://www.semanticweb.org/ontologies/Z#myName"/>
</owl:DatatypeProperty>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Classes
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/ontologies/Z#X -->
<owl:Class rdf:about="http://www.semanticweb.org/ontologies/Z#X">
<rdfs:subClassOf rdf:resource="http://www.semanticweb.org/ontologies/Z#Y"/>
</owl:Class>
<!-- http://www.semanticweb.org/ontologies/Z#Y -->
<owl:Class rdf:about="http://www.semanticweb.org/ontologies/Z#Y"/>
</rdf:RDF>
<!-- Generated by the OWL API (version 3.5.1) http://owlapi.sourceforge.net -->
我在 A.owl
中导入了 Z.owl
。当我 运行 HermiT reasoner 和 A ontology 时。它抛出 org.semanticweb.HermiT.datatypes.UnsupportedDatatypeException
异常。
异常详情:-
Exception in thread "main" org.semanticweb.HermiT.datatypes.UnsupportedDatatypeException: HermiT supports all and only the datatypes of the OWL 2 datatype map, see
http://www.w3.org/TR/owl2-syntax/#Datatype_Maps.
The datatype 'http://www.semanticweb.org/ontologies/Z#myName' is not part of the OWL 2 datatype map and
no custom datatype definition is given;
therefore, HermiT cannot handle this datatype.
我的 JAVA 代码是:-
Configuration reasonerConf = new Configuration();
reasonerConf.throwInconsistentOntologyException = false;
ReasonerFactory factory = new ReasonerFactory();
OWLReasoner reasoner = factory.createReasoner(owlOntology, reasonerConf); //Line where it throws above Exception
owlOntology
是当前工作的 ontology,它是 'A' 加载到 owlManager
(OWLOntologyManager) 中。 'Z' ontology也在这个owlManager
.
我尝试 运行 HermiT 推理机,但它没有抛出任何异常。
您声明了一个数据类型:
<rdfs:Datatype rdf:about="http://www.semanticweb.org/ontologies/Z#myName"/>
但它没有关联的定义。它的词汇形式是什么? "foo"^^ex:myName 是否合法?它是否等同于 "FOO"^^ex:myName 的值? HermiT 没有办法知道这些问题的答案,因此抱怨:
The datatype 'http://www.semanticweb.org/ontologies/Z#myName' is not part of the OWL 2 datatype map and no custom datatype definition is given; therefore, HermiT cannot handle this datatype.
您需要为此数据类型提供某种 HermiT 可以理解的定义,或者可能改用数据类型分面。