如何将JENA OntModel克隆到具有不同ModelSpec的另一个模型 [英] How to clone a JENA OntModel to another with a different ModelSpec

查看:89
本文介绍了如何将JENA OntModel克隆到具有不同ModelSpec的另一个模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在耶拿有一个OWL_MEM_RDFS_INF ModelSpec的OntModel.但是,我创建了一个实用程序来计算模型中的个人,属性等的数量.如此处因为我正在使用某些推理能力,所以花了永久的时间执行model.listIndividuals()方法,这是正常的.

I have an OntModel in Jena with an OWL_MEM_RDFS_INF ModelSpec. However I created a utility to count the number of individuals, properties, etc... in the model. As explained here it takes forever to execute the model.listIndividuals() method which is normal because I am using some reasoning abilities.

它得到了进一步的证明,因为如果我使用基本的OWL_MEM ModelSpec,我不会有任何问题.

It's further demonstrated because if I use the basic OWL_MEM ModelSpec I don't have any problem.

我尝试使用解释的内容克隆模型图并使用另一个ModelSpec

I tried to clone the model graph and use another ModelSpec by using what's explained here:

  Model copyOfOntModel = ModelFactory.createModelForGraph(model.getGraph());
  OntModel newModel = new OntModelImpl(OntModelSpec.OWL_MEM, copyOfOntModel);

但是当我执行model.listIndividuals()方法时,它仍然需要永远的时间.有没有办法克隆模型,但是使用基本的ModelSpec为例?

But it still takes forever when I execute the model.listIndividuals() method. Is there a way to clone the model but use the basic ModelSpec for example?

推荐答案

我应用了UniformedUser所说的内容,但是由于getRawModel()方法不是OntModel的结果,我只是这样做了:

I applied what UniformedUser said, but as as the result of the getRawModel() method is not an OntModel, I just did:

  Model _model = model.getRawModel();
  OntModel newModel = new OntModelImpl(OntModelSpec.OWL_MEM, _model);

它就可以了!

这篇关于如何将JENA OntModel克隆到具有不同ModelSpec的另一个模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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