导入 owl 文件
我在 Java 中使用 owl api 导入 owl 文件时遇到问题。我可以成功导入 2 个 owl 文件。但是,当我尝试导入 3 个或更多相互集成的 owl 文件时,出现了问题。 例如
Base.owl -- base ontology
Electronics.owl -- electronics ontology which imports Base.owl
Telephone.owl -- telephone ontology which imports Base.owl and Electronics.owl
,当我只需导入 Base.owl 并运行 Electronics.owl 时,它就可以顺利运行。代码如下:
File fileBase = new File("filepath/Base.owl");
File fileElectronic = new File("filePath/Electronic.owl");
SimpleIRIMapper iriMapper = new SimpleIRIMapper(IRI.create("url/Base.owl"),
IRI.create(fileBase));
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
manager.addIRIMapper(iriMapper);
OWLOntology ont = manager.loadOntologyFromOntologyDocument(fileElectronic);
但是,当我想要加载 Telephone.owl 时,我只需创建一个额外的 iriMapper 并将其添加到管理器中。附加代码用 ** 显示:
File fileBase = new File("filepath/Base.owl");
File fileElectronic = new File("filePath/Electronic.owl");
**File fileTelephone = new File("filePath/Telephone.owl");**
SimpleIRIMapper iriMapper = new SimpleIRIMapper(IRI.create("url/Base.owl"),
IRI.create(fileBase));
**SimpleIRIMapper iriMapper2 = new SimpleIRIMapper(IRI.create("url/Electronic.owl"),
IRI.create(fileElectronic));**
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
manager.addIRIMapper(iriMapper);
**manager.addIRIMapper(iriMapper2);**
OWLOntology ont = manager.loadOntologyFromOntologyDocument(**fileTelephone**);
上面显示的代码给出了此错误:
Could not load import:
Import(url/Electronic.owl>)
Reason: Could not loaded imported ontology:
<url/Base.owl> Cause: null
如果有人帮助我,我将非常感激...... 提前致谢...
I have a problem with importing owl files using owl api in Java. I successfully can import 2 owl files. However, a problem occurs, when I try to import 3 or more owl files that are integrated to each other.
E.g.
Base.owl -- base ontology
Electronics.owl -- electronics ontology which imports Base.owl
Telephone.owl -- telephone ontology which imports Base.owl and Electronics.owl
When, I just import Base.owl and run Electronics.owl, it works smoothly. The code is given below:
File fileBase = new File("filepath/Base.owl");
File fileElectronic = new File("filePath/Electronic.owl");
SimpleIRIMapper iriMapper = new SimpleIRIMapper(IRI.create("url/Base.owl"),
IRI.create(fileBase));
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
manager.addIRIMapper(iriMapper);
OWLOntology ont = manager.loadOntologyFromOntologyDocument(fileElectronic);
However, when I want to load Telephone.owl, I just create an additional iriMapper and add it to the manager. The additional code is shown with ** :
File fileBase = new File("filepath/Base.owl");
File fileElectronic = new File("filePath/Electronic.owl");
**File fileTelephone = new File("filePath/Telephone.owl");**
SimpleIRIMapper iriMapper = new SimpleIRIMapper(IRI.create("url/Base.owl"),
IRI.create(fileBase));
**SimpleIRIMapper iriMapper2 = new SimpleIRIMapper(IRI.create("url/Electronic.owl"),
IRI.create(fileElectronic));**
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
manager.addIRIMapper(iriMapper);
**manager.addIRIMapper(iriMapper2);**
OWLOntology ont = manager.loadOntologyFromOntologyDocument(**fileTelephone**);
The code shown above gives this error :
Could not load import:
Import(url/Electronic.owl>)
Reason: Could not loaded imported ontology:
<url/Base.owl> Cause: null
It would be really appreciated, if someone gives me a hand...
Thanks in advance...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我知道这个问题很老了,但这是我第一次在谷歌搜索类似问题(加载许多猫头鹰导入)。而我需要很多时间来寻找答案。
因此,对于所有遇到 owlapi 问题的人来说:“无法加载导入的本体”: owlapi 提供了一个名为 “AutoIRIMapper” 的实用程序类(此处描述:http://owlapi.sourceforge.net/2.xx/utilityclasses.html 和 http://owlapi.sourceforge.net/javadoc/index.html)。
创建“AutoIRIMapper”实例后,可以使用以下代码将其添加到“OWLOntologyManager”:
"manager.addIRIMapper(autoIRIMapper);"
之后,OWLOntologyManager 将能够自动加载所有导入的 OWL -文件。
我希望这会对某人有所帮助。
I know this question is old, but it was my first hit on google seraching for a similar problem (loading many owl-imports). And I need a lot of time to find an answer.
So for all who have the problem that the owlapi will say: "Could not loaded imported ontology": The owlapi provides a utility-class named "AutoIRIMapper" (described here: http://owlapi.sourceforge.net/2.x.x/utilityclasses.html and http://owlapi.sourceforge.net/javadoc/index.html).
Once created an instance of "AutoIRIMapper" can be addaded to the "OWLOntologyManager" using the following code:
"manager.addIRIMapper(autoIRIMapper);"
After that the OWLOntologyManager will be able to automatically load all imported OWL-Files.
I hope that will help someone.
如果您想向管理器请求加载在导入语句中声明的本体,您可以使用 makeLoadImportRequest 方法,该方法将 OWLImportsDeclaration 作为参数。
看看是否能解决您的问题。
祝你好运!
if you want to make a request to the manager to load an ontology declared in an imports statement, you can use the makeLoadImportRequest method, which takes an OWLImportsDeclaration as a parameter.
See whether that solves your problem.
Good luck!