MakePrimitiveSubClassesMutuallyDisjoint不起作用

时间:2018-05-06 00:24:22

标签: owl ontology owl-api

我想使用MakePrimitiveSubClassesMutuallyDisjoint使一个类的所有子类不相交。但是使用我的代码,这不会发生:

OWLClass owlClass = createClass(concept.getId());

// Here I recursively create the subclasses 
processByLevel(skos, owlClass, concept.getNarrowerConcepts());

// But at this point all the subclass should have been created and set as subclasses  
MakePrimitiveSubClassesMutuallyDisjoint primitive = new MakePrimitiveSubClassesMutuallyDisjoint(dataFactory, owlClass, ontology);

manager.saveOntology(ontology);

我无法找到如何使用它的示例,我不确定我是否错过了manager可能的步骤(类似于addAxiom但是这一点)。

我无法在方法内部进行调试,但我通过调用此方法检查了递归后设置的子类:

ontology.getSubClassAxiomsForSuperClass(owlClass).size();

结果是预期的结果。

但是,我仍然没有看到由此产生的本体论的任何内容,表明这些类是不相交的。

1 个答案:

答案 0 :(得分:2)

OWLClass owlClass = createClass(concept.getId());

// Here I recursively create the subclasses 
processByLevel(skos, owlClass, concept.getNarrowerConcepts());

// But at this point all the subclass should have been created and set as subclasses  
MakePrimitiveSubClassesMutuallyDisjoint primitive = new MakePrimitiveSubClassesMutuallyDisjoint(dataFactory, owlClass, ontology);

// this line is necessary, it actually changes the content of the ontology
manager.applyChanges(primitive.getChanges());

manager.saveOntology(ontology);