如何使用Protégé-OWL API?

原文地址:http://blog.sina.com.cn/s/blog_7afc04b70101mi4j.html


1 Protégé-OWL API的简单介绍

Protégé-OWL API是专门针对OWL和RDF(S)本体语言的开源Java类库,Protégé-OWL API程序员指南[http://protege.stanford.edu/plugins/owl/api/guide.html]提供了主要类和方法的使用,介绍如何使用Protégé-OWL API加载和保存OWL文件、查询和操作OWL数据模型,以及执行基于描述逻辑的推理。当然,它也可以处理RDF(S )本体,与此对应的类主要有RDFSNamedClass、RDFProperty 和RDFIndividual等。

2 如何使用Protégé-OWL API

Protégé-OWL API是Protégé-OWL被绑定在Protégé的完整安装(在安装Protégé时选择“Everything”)中。获得Protégé-OWL API的Java文档、源代码和一些例子对学习Protégé-OWL API很有帮助。Protégé-OWL API的jar文档被放置于Protégé安装目录下的edu.stanford.smi.protegex.owl包中。

下面以Eclipse为例,介绍使用Protégé-OWL API的使用。经过以上操作后,在Eclipse项目的Java构建路径(Java Build Path)中将所有Jar文件添加为外部Jar文件(程序员指南中的话是“add all the JAR files from the installation to your project classpath”)。这里选择添加\\Protege\plugins\edu.stanford.smi.protegex.owl目录下面的所有Jar文件和\\Protege\目录下的所有Jar文件。于是,就可以成功运行下面的例子了。

// OWLAPIDemoApplication.java源代码

 

import edu.stanford.smi.protege.exception.OntologyLoadException;

import edu.stanford.smi.protegex.owl.model.OWLModel;

import edu.stanford.smi.protegex.owl.model.OWLNamedClass;

import edu.stanford.smi.protegex.owl.ProtegeOWL;

public class test {

    public static void main(String[] args) {

        OWLModel owlModel = null;

try {

owlModel = ProtegeOWL.createJenaOWLModel();

} catch (OntologyLoadException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

        owlModel.getNamespaceManager().setDefaultNamespace("http://hello.com#");

        OWLNamedClass worldClass = owlModel.createOWLNamedClass("World");

        System.out.println("Class URI: " + worldClass.getURI());

    }

}

另外protege官方指导中有这样的提示:

Now let us configure our Java project and write a small "Hello World" application. If you are using a Java IDE such as Eclipse or IntelliJ, select the Protege installation folder as your project home. Next, add all the JAR files from the installation to your project classpath. Set your compiler output path to plugins/classes.

 

[1]      Protégé-OWL API. http://protege.stanford.edu/plugins/owl/api/index.html

[2]      Protégé-OWL API Programmer's Guide. http://protege.stanford.edu/plugins/owl/api/guide.html


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值