从本体创建 Java 类
我有一个本体文件(RDF 格式),它表示我正在编写的应用程序中的实体。我正在使用 Jena,可以通过直接操作三元组来访问概念并创建/访问资源。
为了使事情变得更容易,我创建了一组 Java 类,每个类对应本体中的每种类型的资源,同时牢记它们的继承和属性。例如
public class Agent{
}
,
public class Person extends Agent{
private String name;
}
如果本体包含两种类型的资源,Agent
和Person
,后者是前者的子类。
我意识到创建这些类的过程(以及提取它们的方法)非常单调。如果我在数据库上编写应用程序,我会使用 Hibernate 的配置文件并让它处理细节。
我的问题是:是否有一种工具可以将本体(在 RDF 文件中)作为输入,并创建一组代表本体中概念的 Java 文件,如上面的示例所示? (或者如果耶拿本身可以做到这一点,而我错过了一些东西)
谢谢。
I have an ontology file (in RDF) which expresses the entities in the app that I am writing. I am using Jena, and can access the Concepts and create/access the resources by directly manipulating triples.
To make things easier, I created a set of Java classes, one for each type of resource in my ontology, keeping in mind their inheritances, and properties. E.g.
public class Agent{
}
and
public class Person extends Agent{
private String name;
}
If the ontology contains two types of resources, Agent
and Person
, with the latter being a subclass of the former.
I realized that the process of creating these classes (and the methods to extract them) are very monotonous. If I was writing an application on databases, I would have used a config file for Hibernate and let it take care of the details.
My question is: Is there a tool available that will take an ontology (in an RDF file) as input, and create a set of Java files representing the Concepts in the ontology, as in the example above? (or if Jena itself can do this, and I am missing something)
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
有一些工具,例如 Bouml 和 Andromda,您可以使用它从 XMI UML 序列化生成 Java。
此外,我们还致力于将 UML 与 RDF 集成:http://infolab.stanford。 edu/~melnik/rdf/uml/。
因此,我想您可以找到一种方法将 RDF 转换为 XMI,然后从 XMI 生成 Java,只要您首先将初始 RDF 模式映射到 RDF/UML。
我还刚刚找到了这篇论文:Automatic Mapping of OWL Ontologies into Java 我做了没有阅读所以我无法发表评论。
There are tools such as Bouml and Andromda with which you may generate Java from XMI UML serialization.
Furthermore, work has been done towards integrating UML with RDF: http://infolab.stanford.edu/~melnik/rdf/uml/.
So I guess you could find a way to transform your RDF to XMI then to generate Java from XMI, given you first map your initial RDF schema to RDF/UML.
Also I just found this paper: Automatic Mapping of OWL Ontologies into Java which I did not read so I cannot comment.
Protege 支持 RDF 导入和 java 导出。我过去曾使用它来将本体数据导入到 java 程序中,而且效果相当好。
Protege supports RDF import and java export. I've used it in the past for getting ontology data into java programs and it's worked reasonably.
在浏览上面提供的链接时,我偶然发现了 Trispresso 项目,它提供了很好的总结相关工具及其功能,包括多重继承和代码生成。我认为这可以很好地回答我自己的问题。
While going through the links provided above, I chanced upon the Trispresso Project, which provides a nice summary of the relevant tools and their features, including multiple inheritance and code generation. Thought it would make a good answer to my own question.
您检查过 JRDF 吗?还有其他可用的代码生成工具。请查看此处 。
Did u checked JRDF? There are other code generation tools available too.. Check here.