【问题标题】:OWLAPI : HermiT reasoner thows "UnsupportedDatatypeException" for data type from imported OntologyOWLAPI:HermiT 推理器为导入的本体中的数据类型抛出“UnsupportedDatatypeException”
【发布时间】:2016-07-21 14:28:45
【问题描述】:

我有 2 个本体(通过 Protege 生成)。

本体(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本体(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。当我使用 A 本体运行 HermiT 推理器时。它会抛出 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 是当前工作的本体,它被 'A' 加载到 owlManager (OWLOntologyManager)。 'Z'本体也在这个owlManager中。

我试图在 protege 中运行 HermiT 推理器,但它不会在那里抛出任何异常。

【问题讨论】:

    标签: java ontology protege owl-api


    【解决方案1】:

    你声明了一个数据类型:

    <rdfs:Datatype rdf:about="http://www.semanticweb.org/ontologies/Z#myName"/>
    

    但它没有相关的定义。它的词汇形式是什么? “foo”^^ex:myName 是否合法?它是否等同于“FOO”^^ex:myName 的值? HermiT 没有办法知道这些问题的答案,因此抱怨道:

    数据类型“http://www.semanticweb.org/ontologies/Z#myName”不是 OWL 2 数据类型映射的一部分,并且没有给出自定义数据类型定义;因此,HermiT 无法处理这种数据类型。

    您需要为此数据类型提供 HermiT 可以理解的某种定义,或者改用数据类型方面。

    【讨论】:

    • 我添加了以下代码并且它有效。 &lt;rdfs:Datatype rdf:about="http://www.semanticweb.org/ontologies/Z#myName"&gt; &lt;owl:equivalentClass rdf:resource="&amp;xsd;string"/&gt; &lt;/rdfs:Datatype&gt; 只是想了解更多关于词汇形式和方面的信息。你能提供一些关于它的信息吗?同样在我的问题中,当 HermiT 推理器启动时,Protege 不会给出任何错误。这怎么可能?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-08-10
    • 2021-07-17
    • 1970-01-01
    • 1970-01-01
    • 2020-03-25
    • 2016-12-13
    • 1970-01-01
    相关资源
    最近更新 更多