【问题标题】:OWL 2 ontology consistency checkOWL 2 本体一致性检查
【发布时间】:2015-06-24 07:55:21
【问题描述】:

我正在尝试将 SBVR 规则更改为 Ontologies(OWL 2),然后使用 Hermit Reasoner 对它们进行一致性检查。然而,即使在规则不一致从而本体不一致的情况下,隐士推理者也显示本体是一致的。我不知道哪里出错了。

我得到的本体(OWL 2)如下:

Prefix( xsd:=<http://www.w3.org/2001/XMLSchema#> )
Prefix( ns:=<http://isd.ktu.lt/semantika/> )
Ontology( <http://isd.ktu.lt/semantika/s2o>
Declaration( AnnotationProperty( <ns:s2o#label_sbvr> ) )
Declaration( AnnotationProperty( <ns:s2o#label_en> ) )
Declaration( Class( <ns:s2o#credit_card> ) )
AnnotationAssertion( <ns:s2o#label_sbvr> <ns:s2o#credit_card> "credit_card"@en )
AnnotationAssertion( <http://www.w3.org/2000/01/rdf-schema#label> <ns:s2o#credit_card> "credit card"@en )
AnnotationAssertion( <ns:s2o#label_en> <ns:s2o#credit_card> "credit card" )
Declaration( Class( <ns:s2o#car_rental> ) )
AnnotationAssertion( <ns:s2o#label_sbvr> <ns:s2o#car_rental> "car_rental"@en )
AnnotationAssertion( <http://www.w3.org/2000/01/rdf-schema#label> <ns:s2o#car_rental> "car rental"@en )
AnnotationAssertion( <ns:s2o#label_en> <ns:s2o#car_rental> "car rental" )
Declaration( ObjectProperty( <ns:s2o#is_insured_by__credit_card> ) )
ObjectPropertyDomain( <ns:s2o#is_insured_by__credit_card> <ns:s2o#car_rental> )
ObjectPropertyRange( <ns:s2o#is_insured_by__credit_card> <ns:s2o#credit_card> )
AnnotationAssertion( <ns:s2o#label_sbvr> <ns:s2o#is_insured_by__credit_card> "car_rental is_insured_by credit_card"@en )
AnnotationAssertion( <http://www.w3.org/2000/01/rdf-schema#label> <ns:s2o#is_insured_by__credit_card> "car rental is insured by credit card"@en )
AnnotationAssertion( <ns:s2o#label_en> <ns:s2o#is_insured_by__credit_card> "car rental is insured by credit card" )
SubClassOf( <ns:s2o#car_rental> ObjectMinCardinality( 3 <ns:s2o#is_insured_by__credit_card> <ns:s2o#credit_card> ) )
SubClassOf( <ns:s2o#car_rental> ObjectMaxCardinality( 2 <ns:s2o#is_insured_by__credit_card> <ns:s2o#credit_card> ) )
)

对应的SBVR规则和词汇如下:

词汇

信用卡

汽车租赁

car_rental is_insured_by credit_card

规则

car_rental is_insured_by at_least 3 credit_card 是必要的;

car_rental 需要最多 2 张信用卡投保;

SBVR 规则明显对比,因此不一致。我想知道本体是否也不一致,如果是,为什么推理器不起作用。在我看来确实如此,但我不知道为什么隐士推理者会这么说。

我已将 Hermit.jar 添加到我的 java 代码中并在其上运行推理器。

代码是

    package com.tcs.HermiT;

import java.io.File;

import org.semanticweb.HermiT.Reasoner;
import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyManager;

public class Demo {

    public static void main(String[] args) throws Exception {
        // First, we create an OWLOntologyManager object. The manager will load and save ontologies.
        OWLOntologyManager m = OWLManager.createOWLOntologyManager();
        // We use the OWL API to load the Pizza ontology.
        File inputOntologyFile = new File("C:\\Users\\1047785\\Desktop\\HermiT\\Input9.owl");
        OWLOntology o=m.loadOntologyFromOntologyDocument(inputOntologyFile);// Now, we instantiate HermiT by creating an instance of the Reasoner class in the package org.semanticweb.HermiT.
        Reasoner hermit=new Reasoner(o);
        //System.out.println(hermit.getDLOntology());
        // Finally, we output whether the ontology is consistent.
        System.out.println(hermit.isConsistent());
        //System.out.println(hermit.getDLOntology().toString());

    }
}

【问题讨论】:

  • 将问题减少到极端情况,即只有属性断言冲突的本体(max 2 credit_cardmin 3 credit_card)进入 Protege 并在结果上运行隐士,这对我来说是不一致的信号。你确定你加载的是正确的本体而不是旧版本吗?
  • 不,我正在加载正确的本体。那我猜我的推理机有点毛病。谢谢你的更新。我怀疑这可能是推理者的问题是正确的。与 Protege 中的 Reasoner 相比,Java 中的 Hermit Reasoner(如我的情况)是否可能会有所不同?如果这个问题听起来很愚蠢,我很抱歉。
  • 我对 Hermit 不太熟悉,但您的代码几乎与 the docs 建议的字母完全一致。您可以尝试直接运行from command line 并比较输出。请注意,这也可能是一个简单的语法问题,因为在本体中很容易出现单字符错误。
  • protégé 使用的推理器是 HermiT 作者发布的同一个 jar。
  • @Ignazio:是的,我刚刚检查过了。感谢您早前就无法满足的方法提出的意见。问题是,一旦我让我的本体不一致,通过实例化一个类,函数就会给出一个异常。所以我无法确定导致不一致的类。你能帮忙吗?

标签: xml owl ontology business-rules reasoning


【解决方案1】:

呈现的本体并不矛盾。矛盾的基数限制导致类car_rental 的不可满足性。 HermiT 正确地检测到了这一点,Protege 将这个类标记为红色并将其分类为Nothing 的子类。但是,只要该类不包含实例,本体就保持一致。为了使其由于这些矛盾的限制而不一致,您必须至少具有该类的一个实例。

【讨论】:

  • 非常感谢。我被这个问题困扰了好几天了。
  • 只是澄清一下,通过该类的一个实例,您是指演示类(在我的代码中)还是 OwlOntology 类?
  • 无法满足的类是 car_rental。您可以使用 OWLReasoner.getUnsatisfiableClasses() 获取无法满足的类列表
  • 我的意思是 OWL 类,而不是 Java 类。矛盾的限制迫使类car_rental 为空。如果本体包含使此类非空的公理(例如,ClassAssertion( &lt;ns:s2o#car_rental&gt; &lt;ns:s2o#myCarRental&gt; ),则整个本体变得不一致。
  • @DmitryTsarkov:感谢您的帮助。结果和你说的一模一样。您能否建议一种方法,让我可以打印出导致不一致的 OWL 类?如前所述,Reasoner.getUnsatisfiableClasses 打印 car_rental 作为不一致的来源。但是现在即使答案是错误的,它也会给出一个异常,指出本体不一致。
猜你喜欢
  • 2015-09-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-03-26
  • 2013-01-01
  • 2018-03-18
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多