简体   繁体   English

在Java中查找OWL类

[英]Finding OWL Class in Java

I'm starting to learn about OWL in Java, I've read some tuts including OWL API, Apache Jena, and Protege. 我开始学习Java中的OWL,我读过一些内容,包括OWL API,Apache Jena和Protege。 I want to get the class in owl, but in OWL API it returns the inputted IRI. 我想在owl中获取类,但在OWL API中它返回输入的IRI。

Here's the process: Let's take it that I'm looking for word 'beauty', which is individual of 'Inspector', and 'Inspector' is subclass of 'Guardian'. 这是一个过程:让我们来看看我正在寻找“美丽”这个词,它是“督察”的个体,“督察”是“卫报”的子类。 Currently in my program the output is the IRI of beauty itself. 目前在我的程序中,输出是美丽本身的IRI。 I wanted to get the Inspector IRI and Guardian IRI. 我想获得Inspector IRI和Guardian IRI。

Any help/guide will be appreciated, thanks :) 任何帮助/指南将不胜感激,谢谢:)

If you have an OWLIndividual , then you should be able to call getTypes to get a set of the types that it has, one of which would be the class that you're describing. 如果你有一个OWLIndividual ,那么你应该能够调用getTypes来获得它拥有的一组类型,其中一个类型就是你所描述的类。 (Note that the default toString method some of the OWL API classes might show the IRI of the thing, so simply printing an individual or class might look the same as printing its IRI as a string.) getTypes returns a set of OWLClassExpressions , and once you've got one of those, you could use asOWLClass to get the corresponding class, and then use getSuperClasses to walk up your class hierarchy. (注意,默认的toString方法,一些OWL API类可能会显示事物的IRI,因此简单地打印个人或类可能看起来与将其IRI打印为字符串相同。) getTypes返回一组OWLClassExpressions ,并且一次你有其中一个,你可以使用asOWLClass来获取相应的类,然后使用getSuperClasses来提升你的类层次结构。 Note that, as Ignazio pointed out in the comments , you should only call asOWLClass if the class expression is not anonymous. 请注意,正如Ignazio在评论中指出的那样,如果类表达式不是匿名的, 则只应调用asOWLClass To get a list of superclasses that is guaranteed to be complete, you'll also need to use reasoner that is complete with respect to OWL, which the reasoner built in with OWL API is not. 要获得保证完整的超类列表,您还需要使用与OWL相关的完整推理器,其中使用OWL API构建的推理器不是。

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

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