OWLSAPI示例Word下载.docx

上传人:b****4 文档编号:6342611 上传时间:2023-05-06 格式:DOCX 页数:22 大小:22.90KB
下载 相关 举报
OWLSAPI示例Word下载.docx_第1页
第1页 / 共22页
OWLSAPI示例Word下载.docx_第2页
第2页 / 共22页
OWLSAPI示例Word下载.docx_第3页
第3页 / 共22页
OWLSAPI示例Word下载.docx_第4页
第4页 / 共22页
OWLSAPI示例Word下载.docx_第5页
第5页 / 共22页
OWLSAPI示例Word下载.docx_第6页
第6页 / 共22页
OWLSAPI示例Word下载.docx_第7页
第7页 / 共22页
OWLSAPI示例Word下载.docx_第8页
第8页 / 共22页
OWLSAPI示例Word下载.docx_第9页
第9页 / 共22页
OWLSAPI示例Word下载.docx_第10页
第10页 / 共22页
OWLSAPI示例Word下载.docx_第11页
第11页 / 共22页
OWLSAPI示例Word下载.docx_第12页
第12页 / 共22页
OWLSAPI示例Word下载.docx_第13页
第13页 / 共22页
OWLSAPI示例Word下载.docx_第14页
第14页 / 共22页
OWLSAPI示例Word下载.docx_第15页
第15页 / 共22页
OWLSAPI示例Word下载.docx_第16页
第16页 / 共22页
OWLSAPI示例Word下载.docx_第17页
第17页 / 共22页
OWLSAPI示例Word下载.docx_第18页
第18页 / 共22页
OWLSAPI示例Word下载.docx_第19页
第19页 / 共22页
OWLSAPI示例Word下载.docx_第20页
第20页 / 共22页
亲,该文档总共22页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

OWLSAPI示例Word下载.docx

《OWLSAPI示例Word下载.docx》由会员分享,可在线阅读,更多相关《OWLSAPI示例Word下载.docx(22页珍藏版)》请在冰点文库上搜索。

OWLSAPI示例Word下载.docx

create 

URI 

for 

the 

service 

(note 

that 

this 

is 

0.9 

version 

file) 

uri 

new 

URI("

http:

//www.mindswap.org/2004/owl-s/0.9/ZipCodeFinder.owl"

);

KB 

OWLKnowledgeBase 

kb 

OWLFactory.createKB();

generic 

reader 

and 

1.0 

writer

OWLOntology 

ont 

kb.read(uri);

get 

service

Service 

ont.getService();

write 

output 

to 

console 

(a 

file 

stream 

can 

also 

be 

used 

here)

ont.write(System.out);

将旧服务描述转换为新描述。

验证

缓存Ontology

执行服务:

执行服务意味着执行它的process。

Process应该有有效的grounding说明,以便有效的调用服务。

WSDL和UPnP的grounding由API支持,函数ProcessExecutionEngine.execute(Process, 

ValueMap)可以执行一个process,ValueMap表示输入的值,这个函数返回输出值。

举例如下:

an 

execution 

engine 

ProcessExecutionEngine 

exec 

OWLSFactory.createExecutionEngine();

load 

description

kb.readService("

//www.mindswap.org/2004/owl-s/1.0/Dictionary.owl"

process 

of 

Process 

service.getProcess();

empty 

value 

map

ValueMap 

values 

ValueMap();

set 

input 

parameter

values.setDataValue(process.getInput("

InputString"

), 

"

computer"

);

execute 

with 

given 

bindings

exec.execute(process, 

values);

as 

string

String 

outValue 

values.getStringValue(process.getOutput());

display 

result

System.out.println("

Output 

outValue);

执行跟踪功能:

当执行复杂的服务时,知道执行的过程是很有用的,ProcessExecutionListener就是为这一目的设计的。

ProcessExecutionEngine.addExecutionListener(ProcessExecutionListener)就可以为执行器添加这么一个监听器。

生成复合过程

可以用程序产生服务的descriptions, 

profile或者processes描述。

OWLOntology接口实现了这个功能。

/**

Create 

Sequence 

from 

processes 

services 

put 

them 

in 

new

Service.

@param 

List 

Services

baseURI 

The 

base 

generated 

@return 

which 

*/

createSequenceService(List 

services, 

baseURI) 

ontology

OWLFactory.createOntology();

ont.createService(URI.create(baseURI 

Service"

));

composite 

CompositeProcess 

ont.createCompositeProcess(URI.create(baseURI 

Process"

sequence 

construct

ont.createSequence();

into 

compositeProcess.setComposedOf(sequence);

for(int 

0;

<

services.size();

i++) 

list

(Service) 

services.get(i);

fron 

s.getProcess();

perform 

Perform 

ont.createPreform();

perform.setProcess(p);

sequence

sequence.addComponent(p);

data 

flow 

if 

necessary... 

}

profile...

grounding 

return 

service;

支持功能。

API中包含了org.mindswap.owls.wsdl这个包,可以用来读写WSDL描述的服务。

执行OWL-S服务就是通过这个包实现的。

这个功能是建立在AXIS包1.1上的。

其他应用:

类CreateSequence表明了如何将一系列服务串联起来,并自动产生一个描述新服务的profile,这个类假定每个服务都是单输入单输出的(除了第一个服务和最后一个服务),这样前面的服务的输出将作为后一个服务的输入。

第一个服务不需要有输入,最后一个服务不需要有输出。

组合服务的名字命名为[Service1 

Service2 

... 

ServiceN]。

最后在main函数中进行测试,将BookFinder.owl和BNPrice.owl进行组合,输入"

City 

Glass"

,先查通过BookFinder.owl查到书号,然后将书号输入BNPrice.owl,得到输出:

Executing...done

Book 

Price 

Price:

currency:

USD

amount:

14.00

完整代码如下:

import 

.URI;

java.util.ArrayList;

java.util.List;

org.mindswap.owl.EntityFactory;

org.mindswap.owl.OWLFactory;

org.mindswap.owl.OWLIndividual;

org.mindswap.owl.OWLKnowledgeBase;

org.mindswap.owl.OWLOntology;

org.mindswap.owls.OWLSFactory;

org.mindswap.owls.grounding.Grounding;

org.mindswap.owls.process.AtomicProcess;

org.mindswap.owls.process.CompositeProcess;

org.mindswap.owls.process.Input;

org.mindswap.owls.process.Output;

org.mindswap.owls.process.Perform;

org.mindswap.owls.process.Process;

org.mindswap.owls.process.ProcessList;

org.mindswap.owls.process.Result;

org.mindswap.owls.process.Sequence;

org.mindswap.owls.process.execution.ProcessExecutionEngine;

org.mindswap.owls.profile.Profile;

org.mindswap.owls.service.Service;

org.mindswap.query.ValueMap;

org.mindswap.utils.URIUtils;

org.mindswap.utils.Utils;

An 

example 

show 

how 

descriptions 

created 

on 

fly, 

saved 

executed.

@author 

Evren 

Sirin

public 

class 

CreateSequence 

{

static 

final 

URI.create("

//www.example.org/BookPrice.owl#"

ont;

CreateSequence() 

object 

automatically 

Profile. 

This 

function 

assumes 

that

each 

list 

has 

exactly 

one 

(except 

first 

last 

one) 

such 

resulting 

will 

fed

next 

one. 

does 

not 

have 

need 

output. 

input

(or 

output) 

depending 

this.

objects

services) 

ont.createService(URIUtils.createURI(baseURI, 

TestService"

ont.createCompositeProcess(URIUtils.createURI(baseURI, 

TestProcess"

Profile 

profile 

ont.createProfile(URIUtils.createURI(baseURI, 

TestProfile"

Grounding 

ont.createGrounding(URIUtils.createURI(baseURI, 

TestGrounding"

System.out.println(ont.getKB().getServices());

service.setProfile(profile);

service.setProcess(process);

service.setGrounding(grounding);

createSequenceProcess(process, 

services);

createProfile(profile, 

process);

ProcessList 

process.getComposedOf().getAllProcesses();

list.size();

pc 

list.processAt(i);

if(pc 

instanceof 

AtomicProcess) 

grounding.addGrounding(((AtomicProcess)pc).getGrounding());

profile.setLabel(createLabel(services));

profile.setTextDescription(profile.getLabel());

label 

based 

labels 

services. 

Basically

string 

[Service1 

ServiceN] 

label

Servie 

@return

createLabel(List 

["

;

if(i 

>

0) 

+= 

s.getLabel();

]"

label;

service. 

We 

only 

profile

process.

process

createProfile(Profile 

profile, 

process) 

process.getInputs().size();

Input 

process.getInputs().inputAt(i);

profile.addInput(input);

process.getOutputs().size();

process.getOutputs().outputAt(i);

profile.addOutput(output);

profile;

Creates 

DataFlow 

asssuming 

each

intput 

one).

compositeProcess

grounding

services

createSequenceProcess(CompositeProcess 

compositeProcess, 

Perform[] 

performs 

Perform[services.size()];

performs[i] 

ont.createPerform();

performs[i].setProcess(p);

sequence.addComponent(performs[i]);

prevPerform 

performs[i 

1];

p.getInputs().inputAt(0);

prevPerform.getPr

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 自然科学 > 物理

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2