首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >OWLIM-lite不会推断出任何语句

OWLIM-lite不会推断出任何语句
EN

Stack Overflow用户
提问于 2012-08-27 19:50:18
回答 1查看 459关注 0票数 2

我正在使用OWLIM-lite (5.2)进行owl2rl本体推理。存储公理似乎是可行的,存储库已初始化,但系统不会推断出任何隐式语句(当我查询隐式语句的数量时,系统返回0)。

我还试图查询存储库,系统仅返回显式知识。当我将本体序列化为RDF/XML并使用Pellet在Protege中对其进行推理时,它成功地返回了预期(implicit+explicit)值。

谢谢你的建议。

配置:

代码语言:javascript
复制
[] a rep:Repository ;
   rep:repositoryID "example" ;
   rdfs:label "OWLIM Getting Started" ;
   rep:repositoryImpl [
     rep:repositoryType "openrdf:SailRepository" ;
     sr:sailImpl [
       sail:sailType "swiftowlim:Sail" ; 

       owlim:repository-type "in-memory-repository" ;
       owlim:ruleset "owl2-rl-reduced-optimized" ;
       # owlim:storage-folder "storage" ;

       # OWLIM-SE parameters
       owlim:cache-memory "180m" ; 

       # OWLIM-Lite parameters
       owlim:noPersist "true" ;
       owlim:jobsize "1000" ;
       owlim:new-triples-file "new"

      ]
   ].

存储库初始化:

代码语言:javascript
复制
    private OwlimRepository() throws RepositoryException, RepositoryConfigException, RDFParseException, RDFHandlerException, IOException {
    repositoryManager = new LocalRepositoryManager(new File("."));
    repositoryManager.initialize();

    Graph repositoryRdfDescription = parseFile(new File(this.getClass().getClassLoader().getResource("owlim.ttl").getFile()), RDFFormat.TURTLE, "http://example.org#");
    Iterator<Statement> iter = repositoryRdfDescription.match(null, RDF.TYPE, new URIImpl(
            "http://www.openrdf.org/config/repository#Repository"));
    Resource repositoryNode = null;
    if (iter.hasNext()) {
        Statement st = iter.next();
        repositoryNode = st.getSubject();
    }


    RepositoryConfig repositoryConfig = RepositoryConfig.create(repositoryRdfDescription,
            repositoryNode);
    repositoryManager.addRepositoryConfig(repositoryConfig);
    repository = repositoryManager.getRepository("example");
    repository.initialize();
    valueFactory = repository.getValueFactory();
    repositoryConnection = repository.getConnection();
    repositoryConnection.setAutoCommit(false);

}

如何加载本体:

代码语言:javascript
复制
    public void setRepository(OwlimRepository repository) {
    try {
        this.repository = repository;

        final RDFInserter inserter = new RDFInserter(repository.getRepository().getConnection());

        RDFParser parser = Rio.createParser(RDFFormat.RDFXML);
        parser.setRDFHandler(new RDFHandler() {

            public void startRDF() throws RDFHandlerException {
                inserter.startRDF();
            }

            public void endRDF() throws RDFHandlerException {
                inserter.endRDF();
            }

            public void handleNamespace(String string, String string1) throws RDFHandlerException {
                inserter.handleNamespace(string, string1);
            }

            public void handleStatement(Statement stmnt) throws RDFHandlerException {
                try {
                    System.out.println("inserting: " + stmnt);
                    inserter.handleStatement(stmnt);
                    OwlimSparqlProcessor.this.repository.getRepositoryConnection().commit();
                } catch (RepositoryException ex) {
                    ex.printStackTrace();
                    throw new RuntimeException(ex);

                }
            }

            public void handleComment(String string) throws RDFHandlerException {

                inserter.handleComment(string);

            }
        });
        parser.parse(new BufferedInputStream(new FileInputStream(OwlimSparqlProcessor.class.getClassLoader().getResource("odra-ontology.owl").getFile())), OntologyConstants.ODRA_ONTOLOGY_BASE);
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new RuntimeException(ex);
    }
}

新知识存储:

代码语言:javascript
复制
private void addStatement(URI subject, URI property, URI object) {
    try {
        repositoryConnection.add(subject, property, object);
        repositoryConnection.commit();
    } catch (RepositoryException ex) {
        throw new RuntimeException(ex);
    }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-08-27 22:57:46

终于找到了问题所在。配置是正常的,错误在本体中。OWL2RL不支持(X或Y)形式的超类,因此OWLIM没有对其进行推理。由于Pellet是DL,并具有此功能,因此它的推理符合预期。

我以为owlim会检查符合性,但它没有。因此,如果您遇到类似的问题,请先尝试this profile validator

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12141412

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档