以文本方式查看主题

-  计算机科学论坛  (http://bbs.xml.org.cn/index.asp)
--  『 Semantic Web(语义Web)/描述逻辑/本体 』  (http://bbs.xml.org.cn/list.asp?boardid=2)
----  [求助]请问在Jena中如何将Rule添加到已有的reasoner中?  (http://bbs.xml.org.cn/dispbbs.asp?boardid=2&rootid=&id=46157)


--  作者:blueocean
--  发布时间:4/27/2007 5:15:00 PM

--  [求助]请问在Jena中如何将Rule添加到已有的reasoner中?
OntModel默认的Reasoner,如何将建好的Rule添加到该Reasoner中?
--  作者:jpz6311whu
--  发布时间:4/27/2007 10:28:00 PM

--  
As an illustration suppose that we have a raw data model which asserts three triples:

eg:A eg:p eg:B .
eg:B eg:p eg:C .
eg:C eg:p eg:D .
and suppose that we have a trivial rule set which computes the transitive closure over relation eg:p

    String rules = "[rule1: (?a eg:p ?b) (?b eg:p ?c) -> (?a eg:p ?c)]";
    Reasoner reasoner = new GenericRuleReasoner(Rule.parseRules(rules));
    reasoner.setDerivationLogging(true);
    InfModel inf = ModelFactory.createInfModel(reasoner, rawData);
Then we can query whether eg:A is related through eg:p to eg:D and list the derivation route using the following code fragment:

    PrintWriter out = new PrintWriter(System.out);
    for (StmtIterator i = inf.listStatements(A, p, D); i.hasNext(); ) {
        Statement s = i.nextStatement();
        System.out.println("Statement is " + s);
        for (Iterator id = inf.getDerivation(s); id.hasNext(); ) {
            Derivation deriv = (Derivation) id.next();
            deriv.printTrace(out, true);
        }
    }
    out.flush();

Which generates the output:

Statement is [urn:x-hp:eg/A, urn:x-hp:eg/p, urn:x-hp:eg/D]
Rule rule1 concluded (eg:A eg:p eg:D) <-
    Fact (eg:A eg:p eg:B)
    Rule rule1 concluded (eg:B eg:p eg:D) <-
        Fact (eg:B eg:p eg:C)
        Fact (eg:C eg:p eg:D)


--  作者:iamwym
--  发布时间:4/29/2007 4:21:00 AM

--  
什么叫吧rule添加到reasoner里面?
--  作者:lrn
--  发布时间:4/15/2009 11:47:00 AM

--  
jpz6311whu 说的是构建a raw data model which asserts three triples:

eg:A eg:p eg:B .
eg:B eg:p eg:C .
eg:C eg:p eg:D .

请问,如何将已有OWL文件绑定到REASONER,用自建JENA的RULE来进行推理呢?
急急!!!!
请说详细些,谢谢


--  作者:jpz6311whu
--  发布时间:4/16/2009 8:32:00 PM

--  
把rawData换成“已有OWL文件”即可
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
62.500ms