简体   繁体   English

检索OWL API 4.0中指定个人所属的类

[英]Retrieve Class to which a Named Individual belongs to in OWL API 4.0

Consider a Named Individual "Cow". 考虑一个命名的个人“牛”。 Its Class is also "Cow" and In turn Cow is subclass of Mammal and Mammal is subclass of livingbeing and so on. 它的类别也是“母牛”,而母牛又是哺乳动物的子类,而哺乳动物是生物的子类,依此类推。 if i have access to the OWLNamedIndividual as follows:- 如果我可以按以下方式访问OWLNamedIndividual:-

for (OWLNamedIndividual i : localUni.getIndividualsInSignature())
    {
      Code that should give me ...
      i = Cow (NamedIndividual)
      Class = Cow
      One Level up class = Mammal
    }

i tried the following but to no avail 我尝试了以下但无济于事

System.out.println(i.getEntityType().getName()  );  
System.out.println(i.getEntityType().toString()  );  
System.out.println(i.getTypes(myontology) ); // this would give me error   NoSuchMethodError

Thanks. 谢谢。

getEntityType() only returns OWLCLASS/OWLOBJECTPROPERTY/OWLNAMEDIDIVIDUAL, ie, OWLAPI specific values about what an entity is, not about its role in an ontology or position in a hierarchy. getEntityType()仅返回OWLCLASS / OWLOBJECTPROPERTY / OWLNAMEDIDIVIDUAL,即,关于实体是什么的OWLAPI特定值,而不是关于它在本体中的角色或层次结构中的位置。

Also, it is possible to pun (ie, an OWLNamedIndividual and an OWLClass can have the same IRI), but the two entities are distinct, so from one you cannot go to the other directly. 同样,也可以进行OWLNamedIndividual (即, OWLNamedIndividualOWLClass可以具有相同的IRI),但是两个实体是不同的,因此对于一个实体,您不能直接转到另一个实体。

OWLNamedIndividual.getTypes(OWLOntology) has been removed in version 4. It is possible to achieve the same result with OWLNamedIndividual.getTypes(OWLOntology)已在版本4中删除。使用以下方法可以获得相同的结果

EntitySearcher.getTypes(OWLIndividual, OWLOntology)

Note that the results will only be asserted types for the individual - in order to get inferred results, you need to use an OWLReasoner . 请注意,结果将仅是针对个人的断言类型-为了获得推断的结果,您需要使用OWLReasoner

Reasoners are still built the same way as for OWLAPI 3: https://github.com/owlcs/owlapi/wiki/DL-Queries-with-a-real-reasoner 推理机的构建方式仍与OWLAPI 3相同: https//github.com/owlcs/owlapi/wiki/DL-Queries-with-a-real-reasoner

However there are no releases of reasoners using OWLAPI 4, as far as I know. 但是据我所知,没有使用OWLAPI 4的推理程序版本。 There are a few experimental branches: The version4 branch of JFact is in SNAPSHOT state: https://github.com/owlcs/jfact A HermiT fork working with OWLAPI 4 is available here: https://github.com/ignazio1977/hermit-reasoner Both will need local build to be used. 有几个实验分支:JFact的version4分支处于SNAPSHOT状态: https ://github.com/owlcs/jfact可在此处找到与OWLAPI 4一起使用的HermiT分支: https : //github.com/ignazio1977/hermit -reasoner两者都需要使用本地版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM