gpt4 book ai didi

owl-api - OWL API V5 从本地文件读取本体

转载 作者:行者123 更新时间:2023-12-04 17:43:59 30 4
gpt4 key购买 nike

在链接的当前文档示例中:
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.OWLOntologyFactoryImpl.loadOWLOntology(OWLOntologyFactoryImpl.java:173)
at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.load(OWLOntologyManagerImpl.java:954)
at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:918)
at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntologyFromOntologyDocument(OWLOntologyManagerImpl.java:859)
at glass.main.ontology_Test_main2.readOntology(ontology_Test_main2.java:49)
at glass.main.ontology_Test_main2.main(ontology_Test_main2.java:38)

请注意附件,一个小的测试java项目,链接:

dropbox.com/s/3787a3gsk2bwc26/test.tar.gz?dl=0

请问我做错了什么,我确定这段代码

请您提供正确的方法,并将其添加到链接 https://github.com/owlcs/owlapi/blob/version5/contract/src/test/java/org/semanticweb/owlapi/examples/Examples.java 中的教程示例中

非常感谢你花时间陪伴。
诚挚的问候

最佳答案

你离解决方案很近:

final OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
final OWLOntology ontology = manager.loadOntologyFromOntologyDocument(new File("/home/galigator/myLocalDir/aura.owl"));

只需使用 新文件 而不是 IRI.create

关于owl-api - OWL API V5 从本地文件读取本体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43155834/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com