用耶拿加载猫头鹰文件 [英] Loading owl file with Jena

查看:59
本文介绍了用耶拿加载猫头鹰文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以Jena作为OntModel加载了几个OWL文件(RDF/XML序列化). 对于某些文件,使用ontoModel.read()读取它们时出现错误:

I load several OWL files (RDF/XML serialization) with Jena as OntModel. For some files I get an error when reading them with ontoModel.read():

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/HttpMessage.

我在类路径中有org.apache.httpcore-sources.jar.

当前引起问题的文件是: ontologydesignpatterns.org/cp/owl/timeindexedpersonrole.猫头鹰

The file which currently poses problem is: ontologydesignpatterns.org/cp/owl/timeindexedpersonrole.owl

我使用Protege将其保存为RDF/XML,并尝试使用扩展名.owl.rdf.

I saved it with Protege as RDF/XML, trying with both extensions .owl and .rdf.

代码:

public static OntModel getOntologyModel(String ontoFile)
{   
    OntModel ontoModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, null);
    try 
    {
        InputStream in = FileManager.get().open(ontoFile);
        try 
        {
            ontoModel.read(in, null);
        } 
        catch (Exception e) 
        {
            e.printStackTrace();
        }
        LOGGER.info("Ontology " + ontoFile + " loaded.");
    } 
    catch (JenaException je) 
    {
        System.err.println("ERROR" + je.getMessage());
        je.printStackTrace();
        System.exit(0);
    }
    return ontoModel;
}

非常感谢您的帮助.

推荐答案

如果使用二进制下载,请将所有jar放在类路径的lib/目录中. org.apache.httpcore-sources.jar不是正确的jar.您似乎至少缺少httpclient-4.2.6.jar和httpcore-4.2.5.jar.

If you are using the binary download, put all the jars in the lib/ directory on the classpath. org.apache.httpcore-sources.jar isn't the right jar.. You seem to be missing at least httpclient-4.2.6.jar and httpcore-4.2.5.jar.

如果您使用Maven,请使用工件:

If you use maven, use the artifact:

<dependency>
 <groupId>org.apache.jena</groupId>
 <artifactId>apache-jena-libs</artifactId>
 <type>pom</type>
 <version>X.Y.Z</version>
</dependency> 

得到相同的集合,但是由maven或您正在使用的任何builer管理.

to get the same set, but managed by maven, or whatever builer you are using.

这篇关于用耶拿加载猫头鹰文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆