如何检查类之间是否存在OWL ObjectProperty表达式?

时间:2015-02-22 18:45:49

标签: rdf semantic-web owl owl-api reasoning

假设有两种类型,一种是(A)和#34; isManagedBy"由另一个(B)。以下owl snipped说明了这种情况。有多个类型A(其中"由"其他类管理)和多个B类。实际上,类型A和B类之间也存在层次结构。

<owl:ObjectProperty rdf:about="#isManagedBy"/>


<owl:Class rdf:about="#FunctionManagement">
 <rdfs:subClassOf rdf:resource="..."/>
 <rdfs:subClassOf>
   <owl:Restriction>
    <owl:onProperty rdf:resource="#isManagedBy"/>
    <owl:someValuesFrom rdf:resource="#SymposiumPlanner2013"/>
   </owl:Restriction>
  </rdfs:subClassOf>
</owl:Class>


<owl:Class rdf:about="#SymposiumPlanner2013"/>
...

问题:在给定任意类A的情况下获取类型B的所有类。

想法:迭代所有类型B的类。对于每个类B,检查给定的A是否具有ObjectProperty&#34; isManagedBy&#34; (直接或继承)使用Reasoner的isSatisfiable()方法到B类。

OWLObjectProperty objProp = df.getOWLObjectProperty(IRI.create("#isManagedBy"));
OWLClassExpression expression;
for (OWLClass B : SetOfAllBs) {
 expression = df.getOWLObjectIntersectionOf(A, df.getOWLObjectSomeValuesFrom(objProp, B));
 if (reasoner.isSatisfiable(expression)) {
   // do something
 }
}

不幸的是,推理器返回的所有B类都可以满足。

问题:如何解决这个问题?

2 个答案:

答案 0 :(得分:1)

你不想在这里检查是否满足,因为它只告诉你是否能够拥有该类的实例。你所追求的是它的实际实例。由于可能存在类的层次结构,因此您需要使用:

reasoner.getInstances(expression, false)

将为您提供直接和间接的实例。

编辑:来自评论,看起来像是在isManagedBy域中的A的子类之后,或者对于isManagedBy的限制,将B的子类作为范围。

reasoner.getSubClasses(expression, false)这样的东西可能更接近你期望看到的东西。

答案 1 :(得分:1)

我可以为您的问题提出两种解决方案:

  1. 通过所有B,但检查可满足性 A and (isManagedBy only (not B))。如果某个B的表达式不可满足,那么这个B必须通过isManagedBy与给定的A相关联。

  2. 如果您使用FaCT ++进行推理,您可以使用OWLKnowledgeExplorerReasoner界面来探索在A类的可满足性检查期间生成的模型。这个想法是,如果模型中存在这样的B,然后它必须连接到A.有一些限制(它可能不适用于通过EquivalentClasses(B,...)定义的Bs,对于非确定性标签并不总是如此(请参阅getObjectLabel()中的标志true)电话),但这是一个想法。代码可能看起来像:

    OWLReasoner factplusplus = new FactPlusPluReasonerFactore().createReasoner(o);
    OWLKnowledgeExplorerReasoner ke = (OWLKnowledgeExplorerReasoner) factplusplus;
    RootNode nodeForA = ke.getRoot(A);
    for (RootNode filler: ke.getObjectNeighbours(nodeForA, isManagedBy))
        for (OWLClassExpression cls: ke.getObjectLabel(filler,true)
            if ( SetAllBs.contains(cls) )
                /* cls is what you are looking for */