如何检索具有必要和充分限制的所有 类 的集合

How to retrieve the set of all classes that have necessary and sufficient restrictions

在 OWL API 中我们可以检索:

我想要的是从 ontology 中检索 all Defined classes ( classes 有足够的限制,即非原始 classes)。

请问我们该怎么做?

例如:

OWLClass CheesyPizza = factory.getOWLClass(":CheesyPizza",pm); 
OWLClassExpression hasCheese_some_restriction = 
            factory.getOWLObjectSomeValuesFrom(hasTopping, CheeseTopping);
OWLClassExpression Pizza_hasCheeseTopping_intersection =
            factory.getOWLObjectIntersectionOf(Pizza, hasCheese_some_restriction);
OWLEquivalentClassesAxiom CheesyPizza_Definition = 
            factory.getOWLEquivalentClassesAxiom(CheesyPizza, Pizza_hasCheeseTopping_intersection);
tempChange.add(new AddAxiom(localOntology, CheesyPizza_Definition));
managerLocal.applyChanges(tempChange);

Cheesy Pizza 是 Definedclass,假设我们在 Ontology 许多其他定义的 类(classes 具有必要性和充分性)。 我想获得那些 classes(换句话说,我想获得在 protege 的黄色图标中有三行的 classes)。

我知道没有速记功能可以做到这一点。因此我添加了代码的第 2 部分:

OWLOntologyWalker walker = new OWLOntologyWalker(Collections.singleton(localOntology));
OWLOntologyWalkerVisitorEx<Object> visitor = new OWLOntologyWalkerVisitorEx<Object>(walker)
{
 @Override
 public Object visit(OWLEquivalentClassesAxiom ce)
  {
  System.out.println(" " + getCurrentAxiom());
// this will print the relating axioms EquivalentClasses(<http://www.semanticweb.org/ontologies/myontology/CheesyPizza> ObjectIntersectionOf(<http://www.semanticweb.org/ontologies/myontology/Pizza> ObjectSomeValuesFrom(<http://www.semanticweb.org/ontologies/myontology/hasTopping> <http://www.semanticweb.org/ontologies/myontology/CheeseTopping>)) )
// this axioms is correct and it is the axiom we want
// now lets try to get our Class CheesyPizza!
  for (OWLClass clazz : getCurrentAxiom().getClassesInSignature())  
  {
  if(! clazz.isAnonymous())
  System.out.println(clazz);
// this is printing 
//<http://www.semanticweb.org/ontologies/myontology/CheesyPizza>
//<http://www.semanticweb.org/ontologies/myontology/CheeseTopping>
//<http://www.semanticweb.org/ontologies/myontology/Pizza>
  }
}

我只想获取 CheesyPizza,Cheesy Pizza 的定义如代码的第一部分所示,相当于 class pizza 和 [= 交集的匿名 class 51=].

如何获得 CheesyPizza class(它是唯一的 class 不是匿名的并且附有 OWLEquivalent类Axiom . 为什么这么复杂?:(

第 5 版的 OWLOntology::getAxioms(OWLClass c)OWLOntology::axioms(OWLClass c) 应该可以满足您的需求。