OWL Api,将班级从父母A搬到B [英] OWL Api, move class from parent A to B

查看:135
本文介绍了OWL Api,将班级从父母A搬到B的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对owl api的用法有一个简单的问题。

I'm having a quick question regarding the usage of the owl api.

我说有一个名为Species的类,它有一个Subclass哺乳动物,它有一个子类灵长类动物,它有一个子类人类。

Say I have a class called Species, which has a Subclass mammal, which has a Subclass Primate, which has a subclass 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?

找到我们的父类很容易,使用owl-api

Finding our the parent class is easy enough, using the owl-api

reasoner.getSuperClasses(chield, true).entities().collect(Collectors.toSet[OWLClass])

但我如何才能从我父母那里分离我的班级?

but how can I 'detach' my class now from it's parent?

推荐答案

如果你有一个ontolog y关系所在:

If you have an ontology where the relations :


  • 物种 - >哺乳动物

  • 哺乳动物 - >灵长类动物

  • primate - > human

是直接断言的(不是推理计算的结果)。

are directly asserted (not the result of a reasoning computation).

然后在owlapi中,这表示为公理:

Then in owlapi this is represented as axioms :


  1. OWLSubClass(哺乳动物,物种)

  2. OWLSubClass(灵长类动物,哺乳动物)

  3. OWLSubClass(人类,灵长类动物)

解决办法可能是删除旧的subClass断言并添加新的断言(除非你正在使用Allen-temporal)。

The solution could be to remove the old subClass assertion and add the new one (unless you are playing with Allen-temporal).

OWLDataFactory factory = manager.getOWLDataFactory();
ontology.remove(factory.getOWLSubClassOfAxiom(primate, mammal));
ontology.add(factory.getOWLSubClassOfAxiom(primate, species));

注意:如果您使用的是旧版本的owlapi,那么我们必须使用OWLOntologyManager删除/在本体中添加公理:

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 :

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.

这篇关于OWL Api,将班级从父母A搬到B的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆