【发布时间】: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_card,min 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