【问题标题】:OwlReadyInconsistentOntologyError while running Hermit resoner with OWLReady library使用 OWLReady 库运行 Hermit resoner 时出现 OwlReadyInconsistentOntologyError
【发布时间】:2020-02-09 11:35:49
【问题描述】:

我有一个使用 python 和 OWLReady 创建的简单本体文件,当我尝试与 以下代码显示

OwlReadyInconsistentOntologyError: 
C:\ProgramData\Anaconda3\lib\site-packages\owlready2\reasoning.py in sync_reasoner_hermit(x, infer_property_values, debug, keep_tmp_file)
    134     except subprocess.CalledProcessError as e:
    135       if (e.returncode == 1) and (b"Inconsistent ontology" in (e.output or b"")):
--> 136         raise OwlReadyInconsistentOntologyError()
    137       else:
    138         raise OwlReadyJavaError("Java error message is:\n%s" % (e.stderr or e.output or b"").decode("utf8"))

OwlReadyInconsistentOntologyError:

这是我试过的本体文件

<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
         xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
         xmlns:owl="http://www.w3.org/2002/07/owl#"
         xml:base="http://elearn.org/onto.owl"
         xmlns="http://elearn.org/onto.owl#">

<owl:Ontology rdf:about="http://elearn.org/onto.owl"/>

<owl:DatatypeProperty rdf:about="#Age">
  <rdfs:domain rdf:resource="#Learner"/>
  <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
</owl:DatatypeProperty>

<owl:DatatypeProperty rdf:about="#Name">
  <rdfs:domain rdf:resource="#Learner"/>
  <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
</owl:DatatypeProperty>

<owl:DatatypeProperty rdf:about="#Gender">
  <rdfs:domain rdf:resource="#Learner"/>
  <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
</owl:DatatypeProperty>

<owl:DatatypeProperty rdf:about="#Qualification">
  <rdfs:domain rdf:resource="#Learner"/>
  <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
</owl:DatatypeProperty>

<owl:DatatypeProperty rdf:about="#Branch">
  <rdfs:domain rdf:resource="#Learner"/>
  <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
</owl:DatatypeProperty>

<owl:DatatypeProperty rdf:about="#Background_Knowledge">
  <rdfs:domain rdf:resource="#Learner"/>
  <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#integer"/>
</owl:DatatypeProperty>

<owl:DatatypeProperty rdf:about="#Active_Reflective">
  <rdfs:domain rdf:resource="#Learner"/>
  <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#integer"/>
</owl:DatatypeProperty>

<owl:DatatypeProperty rdf:about="#AR_Value">
  <rdfs:domain rdf:resource="#Learner"/>
  <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#integer"/>
</owl:DatatypeProperty>

<owl:DatatypeProperty rdf:about="#Sensitive_Intutive">
  <rdfs:domain rdf:resource="#Learner"/>
  <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#integer"/>
</owl:DatatypeProperty>

<owl:DatatypeProperty rdf:about="#S_I_Value">
  <rdfs:domain rdf:resource="#Learner"/>
  <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#integer"/>
</owl:DatatypeProperty>

<owl:DatatypeProperty rdf:about="#Visual_Verbal">
  <rdfs:domain rdf:resource="#Learner"/>
  <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#integer"/>
</owl:DatatypeProperty>

<owl:DatatypeProperty rdf:about="#V_V_Value">
  <rdfs:domain rdf:resource="#Learner"/>
  <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#integer"/>
</owl:DatatypeProperty>

<owl:DatatypeProperty rdf:about="#Global_Sequential">
  <rdfs:domain rdf:resource="#Learner"/>
  <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#integer"/>
</owl:DatatypeProperty>

<owl:DatatypeProperty rdf:about="#G_S_Value">
  <rdfs:domain rdf:resource="#Learner"/>
  <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#integer"/>
</owl:DatatypeProperty>

<owl:Class rdf:about="#Learner">
  <rdfs:subClassOf rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
</owl:Class>

<Learner rdf:about="#L1">
  <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
  <Age rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">18</Age>
  <Name rdf:datatype="http://www.w3.org/2001/XMLSchema#string">L1</Name>
  <Gender rdf:datatype="http://www.w3.org/2001/XMLSchema#string">M</Gender>
  <Qualification rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">0</Qualification>
  <Branch rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Mathematics with Computer</Branch>
  <Background_Knowledge rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">0</Background_Knowledge>
  <Active_Reflective rdf:datatype="http://www.w3.org/2001/XMLSchema#string">1</Active_Reflective>
  <AR_Value rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">70</AR_Value>
  <Sensitive_Intutive rdf:datatype="http://www.w3.org/2001/XMLSchema#string">0</Sensitive_Intutive>
  <S_I_Value rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">40</S_I_Value>
  <Visual_Verbal rdf:datatype="http://www.w3.org/2001/XMLSchema#string">1</Visual_Verbal>
  <V_V_Value rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">60</V_V_Value>
  <Global_Sequential rdf:datatype="http://www.w3.org/2001/XMLSchema#string">0</Global_Sequential>
  <G_S_Value rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">50</G_S_Value>
</Learner>


</rdf:RDF>

这是python代码

 from owlready2 import *
    from rdflib.graph import Graph
    world = World()
    world.get_ontology("sample_ont.owl").load()
    sync_reasoner(world)
    graph = world.as_rdflib_graph()

我使用相同的代码打开了我使用 Jena API 创建的另一个文件(不是同一个本体),没有错误 什么是 OwlReadyInconsistentOntologyError ? 我该如何解决这个问题?

【问题讨论】:

  • 您拥有范围为 xsd:string 但使用 xsd:integer 值断言的数据属性。这是不一致的,因为 xsd:string 和 xsd:integer 是不相交的数据类型。

标签: python ontology owlready


【解决方案1】:

它给你这个错误是因为隐士推理器发现你的本体不一致。这使用基于描述逻辑的人工智能推理程序来查找本体语句中的逻辑错误。您的其他本体没有给出错误,因为它没有发现任何逻辑不一致。您可以使用 Protege 自行检查,您可以下载 here。

如果你在 Protege 中打开你的本体并运行 Hermit 推理器,它会指出你的本体不一致,它会提供不一致的原因。这是 Protege 中显示的不一致的屏幕截图:

查看它指出的第一个不一致

 Global_Sequential Range: xsd:integer
 L1 Global_Sequential "0" ^^xsd:string

第一行指出Global_Sequential 数据属性的范围是xsd:integer。这意味着每当一个人通过Global_Sequential 数据属性链接到一个值时,该值应该是一个整数。

第二行指出个人L1 通过Global_Sequential 数据属性链接到xsd:string。这就是本体不一致的原因。对于个人 Li,您应该提供一个整数值,而不是一个字符串值。

对于个人L1,数据属性Active_Refelective、Visual_Verbal 和Age 也犯了类似的错误。在Sensitive_Intuitive 的情况下,数据属性需要一个字符串,但提供了一个整数。

为L1 个人修复所有这些值将使您的本体保持一致。

【讨论】:

    猜你喜欢
    • 2020-10-18
    • 1970-01-01
    • 2019-06-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多