`
DigitalSonic
  • 浏览: 210232 次
社区版块
存档分类
最新评论

第一次用OWL-S API

阅读更多

看了好久的论文,终于要开始动手实践了,虽然目标还不是很明确,但照着Demo做东西偶还是会滴。OWL-S API是专门用来处理OWL-S的一个Java开发包,自然是应该放在Java里用的,可是好久没有写JRuby了,所以第一次的小程序就用JRuby来写吧,哈哈~

require 'java'

dir 
= Dir.new("../lib")
dir.each { 
|filename|
    $CLASSPATH 
<< "../lib/#{filename}" if filename =~ /.*.jar/
}

import org.mindswap.owl.OWLFactory
import org.mindswap.owls.OWLSFactory
import org.mindswap.query.ValueMap

exec = OWLSFactory.create_execution_engine()
kb 
= OWLFactory.create_kb()
service 
= kb.read_service("http://www.mindswap.org/2004/owl-s/1.1/Dictionary.owl")
process 
= service.get_process()
input_value_map 
= ValueMap.new()
"pls input a word:"
word 
= gets
input_value_map.set_data_value(process.get_input(
"InputString"), word)
output_value_map 
= exec.execute(process, input_value_map)
out 
= output_value_map.get_value(process.get_output())
p out.get_value();

程序中先引入了JRuby的Java支持,随后将放在../lib目录中的OWL-S API所需的所有jar包引入Classpath,再导入程序中要使用的Java类,后面的操作就和OWL-S API的Demo中的差不多了。

OWL-S API:http://www.mindswap.org/2004/owl-s/api/
上文Demo:http://www.mindswap.org/2004/owl-s/api/doc/#exec

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics