[英]OWL Api, move class from parent A to B
I'm having a quick question regarding the usage of the owl api. 我对owl api的用法有一个快速的问题。
Say I have a class called Species, which has a Subclass mammal, which has a Subclass Primate, which has a subclass Human. 假设我有一个名为Species的类,它有一个Subclass哺乳动物,它有一个Subclass Primate,它有一个子类Human。
species -> mammal -> primate -> human 物种 - >哺乳动物 - >灵长类动物 - >人类
For some reason, I would like to reclassify this in our software and say that Primates are not longer considered Mammals, instead they should be a direct subclass of a Species. 出于某种原因,我想在我们的软件中重新分类,并说灵长类动物不再被认为是哺乳动物,而是它们应该是物种的直接子类。
Meaning our graph should look like this now 这意味着我们的图表现在应该是这样的
species -> primate -> human 物种 - >灵长类动物 - >人类
can anybody please point me in the right direction? 任何人都可以指出我正确的方向吗?
Finding our the parent class is easy enough, using the owl-api 使用owl-api找到我们的父类很容易
reasoner.getSuperClasses(chield, true).entities().collect(Collectors.toSet[OWLClass])
but how can I 'detach' my class now from it's parent? 但是我如何才能从我父母那里“分离”我的班级?
If you have an ontology where the relations : 如果你有一个关系的本体论:
are directly asserted (not the result of a reasoning computation). 直接断言(不是推理计算的结果)。
Then in owlapi this is represented as axioms : 然后在owlapi中,这表示为公理:
The solution could be to remove the old subClass assertion and add the new one (unless you are playing with Allen-temporal). 解决方案可能是删除旧的subClass断言并添加新的断言(除非你正在使用Allen-temporal)。
OWLDataFactory factory = manager.getOWLDataFactory();
ontology.remove(factory.getOWLSubClassOfAxiom(primate, mammal));
ontology.add(factory.getOWLSubClassOfAxiom(primate, species));
Note : if you are using a version older than 5 of owlapi then we must use the OWLOntologyManager to remove/add axioms in an ontology : 注意:如果您使用的是owlapi版本低于5的版本,那么我们必须使用OWLOntologyManager删除/添加本体中的公理:
manager.remove(ontology, axiom)
manager.add(ontology, axiom)
If the specialization relation aren't directly asserted in your ontology; 如果在您的本体中没有直接断言专业化关系; it will be far more complex.
它会复杂得多。 You have to know why 'human' is view a subclass of 'mammal'.
你必须知道为什么'人类'被视为'哺乳动物'的子类。 Maybe the 'explanation' system of the 'reasoner' can help you.
也许'推理'的'解释'系统可以帮助你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.