以文本方式查看主题

-  计算机科学论坛  (http://bbs.xml.org.cn/index.asp)
--  『 Semantic Web(语义Web)/描述逻辑/本体 』  (http://bbs.xml.org.cn/list.asp?boardid=2)
----  请问jena如何只在规则上推理?  (http://bbs.xml.org.cn/dispbbs.asp?boardid=2&rootid=&id=51049)


--  作者:w3cbobo
--  发布时间:8/7/2007 10:06:00 AM

--  请问jena如何只在规则上推理?
我是新手,不知道是不是表述清楚了
我就是想只在owl的规则上进行推理,不使用instance,可是api上的推理好像都要用instance吧,像CreateInfModel(Reasoner reasoner,Model model)这样的。

--  作者:jpz6311whu
--  发布时间:8/7/2007 10:14:00 AM

--  
可以使用jena的自定义规则推理来实现
--  作者:w3cbobo
--  发布时间:8/7/2007 10:26:00 AM

--  
谢谢 jpz6311whu兄,不知能否在说详细点,还是不太明白
我看api的意思好像是一定得这么写:
Model schema=ModelLoader.loadModel("schema.owl");
Model data=ModelLoader.loadModel("data.owl");
Reasoner reasoner=new Reasoner();
reasoner=reasoner.bindSchema(schema);
InfModel=ModelFactory.createInfModel(reasoner,data);

没见到只要owl规则就可以的推理啊......


--  作者:jpz6311whu
--  发布时间:8/7/2007 10:36:00 AM

--  
com.hp.hpl.jena.reasoner
Interface Reasoner

Reasoner是接口,不能Reasoner reasoner=new Reasoner();


--  作者:w3cbobo
--  发布时间:8/7/2007 10:44:00 AM

--  
嗯,是的
Model schema=ModelLoader.loadModel("schema.owl");
Model data=ModelLoader.loadModel("data.rdf");
String domaintbox="一些领域的rules";
Reasoner reasoner=new GenericRuleReasoner(Rule.parseRules(domaintbox));
reasoner=reasoner.bindSchema(schema);
InfModel=ModelFactory.createInfModel(reasoner,data);
这样应该就对了吧

可是 我的问题是这样做还是用了data了阿  因为那个data.rdf里存的实际上就是instance


--  作者:jpz6311whu
--  发布时间:8/7/2007 10:53:00 AM

--  
String domaintbox="一些领域的rules";
这里的规则只写tbox相关的就可以不用data了呀
不太明白楼主问什么?
--  作者:w3cbobo
--  发布时间:8/7/2007 11:00:00 AM

--  
嘿嘿嘿,见笑,我看jena的api上写的是
createInfModel

public static InfModel createInfModel(Reasoner reasoner,Model model)

Build an inferred model by attaching the given RDF model to the given reasoner.

Parameters:
reasoner - the reasoner to use to process the data
model - the Model containing both instance data and schema assertions to be inferenced over

第二个参数不是指明了要“instance data ”的么?

jpz6311whu兄你觉得如果完全不用instance上面的代码要怎么改改呢?


--  作者:jpz6311whu
--  发布时间:8/7/2007 11:03:00 AM

--  
Model schema=ModelLoader.loadModel("schema.owl");

String domaintbox="一些领域的rules";
Reasoner reasoner=new GenericRuleReasoner(Rule.parseRules(domaintbox));

InfModel=ModelFactory.createInfModel(reasoner,schema);


--  作者:w3cbobo
--  发布时间:8/7/2007 11:10:00 AM

--  
谢谢jpz6311whu兄,看来还是要多看看阿

另外再稍带问个问题,ontmodel和infmodel哪个比较强些,只知道好像ont是inf的子类


--  作者:jpz6311whu
--  发布时间:8/7/2007 11:14:00 AM

--  
“强”是什么意思?
--  作者:w3cbobo
--  发布时间:8/7/2007 11:54:00 AM

--  
sorry
刚被老板叫去汇报了

我想问的是哪个更适合在owl上推理用呢?


--  作者:jpz6311whu
--  发布时间:8/7/2007 12:29:00 PM

--  
都可以
--  作者:w3cbobo
--  发布时间:8/7/2007 2:47:00 PM

--  
谢谢~~
--  作者:ejun_2006
--  发布时间:8/10/2007 11:04:00 AM

--  
呵呵
--  作者:blueocean
--  发布时间:8/13/2007 12:20:00 AM

--  
我想问一下,在规则当中,属性要怎么写?

单单写属性名肯定是不行的,我看很多都是“eg:xxx“,这能行吗?


--  作者:jpz6311whu
--  发布时间:8/13/2007 9:46:00 AM

--  
以下是引用blueocean在2007-8-13 0:20:00的发言:
我想问一下,在规则当中,属性要怎么写?

单单写属性名肯定是不行的,我看很多都是“eg:xxx“,这能行吗?



要注册prefix
--  作者:blueocean
--  发布时间:8/13/2007 9:13:00 PM

--  
以下是引用jpz6311whu在2007-8-13 9:46:00的发言:
[quote]以下是引用blueocean在2007-8-13 0:20:00的发言:
我想问一下,在规则当中,属性要怎么写?

  单单写属性名肯定是不行的,我看很多都是“eg:xxx“,这能行吗?
[/quote]
要注册prefix


要如何注册啊?谢了


--  作者:jpz6311whu
--  发布时间:8/14/2007 1:33:00 PM

--  
# ...
A comment line.
// ...
A comment line.


@prefix pre: <http://domain/url#>.
Defines a prefix pre which can be used in the rules. The prefix is local to the rule file.


@include <urlToRuleFile>.
Includes the rules defined in the given file in this file. The included rules will appear before the user defined rules, irrespective of where in the file the @include directive appears. A set of special cases is supported to allow a rule file to include the predefined rules for RDFS and OWL - in place of a real URL for a rule file use one of the keywords RDFS OWL OWLMicro OWLMini (case insensitive).

So an example complete rule file which includes the RDFS rules and defines a single extra rule is:

# Example rule file
@prefix pre: <http://jena.hpl.hp.com/prefix#>.
@include <RDFS>.

[rule1: (?f pre:father ?a) (?u pre:brother ?f) -> (?u pre:uncle ?a)]


--  作者:blueocean
--  发布时间:8/27/2007 3:22:00 AM

--  
汗,这注册prefix个是在命令行下的,
可以在程序代码中实现吗?
--  作者:jpz6311whu
--  发布时间:8/27/2007 10:10:00 AM

--  
以下是引用blueocean在2007-8-27 3:22:00的发言:
汗,这注册prefix个是在命令行下的,
可以在程序代码中实现吗?


不是命令行下的
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
93.750ms