在链接的当前文档示例中:
https://github.com/owlcs/owlapi/blob/version5/contract/src/test/java/org/semanticweb/owlapi/examples/Examples.java
没有如何从本地文件加载本体的示例.只有一种方法可以从字符串加载它.
在过去我使用owl-api版本3
以下代码完美运行:
OWLOntologyManager manager =OWLManager.createOWLOntologyManager();
File file = new File (path);
OWLOntology ont = manager.loadOntologyFromOntologyDocument(IRI.create(file));
但是,在此版本中,前一代码的最后一行:
manager.loadOntologyFromOntologyDocument(IRI.create(file));
返回此错误:
Exception in thread "main" java.lang.NoSuchMethodError:
org.semanticweb.owlapi.util.SAXParsers.initParserWithOWLAPIStandards(Lorg/xml/sax/ext/DeclHandler;)Ljavax/xml/parsers/SAXParser;
at
org.semanticweb.owlapi.rdf.rdfxml.parser.RDFParser.parse(RDFParser.java:148)
at org.semanticweb.owlapi.rdf.rdfxml.parser.RDFXMLParser.parse(RDFXMLParser.java:62)
at uk.ac.manchester.cs.owl.owlapi.OWLO

在尝试使用OWL API V5从本地文件加载OWL本体时遇到错误,旧版代码不再适用。错误信息指向'SAXParsers.initParserWithOWLAPIStandards'方法。已提供包含问题代码的测试Java项目链接,寻求解决方案。
最低0.47元/天 解锁文章
803

被折叠的 条评论
为什么被折叠?



