How to check if OWLObjectPropertyExpression between classes exists?

眉间皱痕 提交于 2020-01-03 04:50:50

问题


Assuming two types of classes, one (A) "isManagedBy" by the other (B). The following owl snipped illustrates this scenario. There are multiple classes of type A (which are "managed by" other classes) and multiple classes of B. In fact, there is also a hierarchy between between classes bot of type A and 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"/>
...

Problem: Get all classes of type B given an arbitrary class A.

Idea: Iterate over all classes of type B. For each class B, check whether a given A has an ObjectProperty "isManagedBy" (directly or inherited) to class B by using a Reasoner's isSatisfiable() method.

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
 }
}

Unfortunately, the reasoner returns satisfiable for all classes of type B.

Question: How to solve this problem?


回答1:


I can suggest two solutions to your problem:

  1. Go through all Bs, but instead check satisfiability of A and (isManagedBy only (not B)). If this expression is unsatisfiable for some B, then such B has to be connected with a given A via isManagedBy.

  2. If you are using FaCT++ for reasoning, you can use the OWLKnowledgeExplorerReasoner interface to explore the models produced during the satisfiability check of a class A. The idea is that if such B present in the model, then it has to be connected to A. There are some limitations (it might not work for Bs defined via EquivalentClasses(B,...), it is not always true for non-deterministic labels (see flag true in the getObjectLabel() call), but here is an idea. The code might looks like:

    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 */
    



回答2:


You don't want to check for satisfiability here, as it only tells you if you would be able to have an instance of that class. What you are after are actual instances of it. As there might be a hierarchy of classes, you want to use:

reasoner.getInstances(expression, false)

which will give you direct and indirect instances.

Edit: from comments, looks like you are after subclasses of A that are in the domain of isManagedBy, or for which restrictions over isManagedBy have subclasses of B as range.

Something like reasoner.getSubClasses(expression, false) might be closer to what you expect to see.



来源:https://stackoverflow.com/questions/28661775/how-to-check-if-owlobjectpropertyexpression-between-classes-exists

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!