无法解析某些本体

问题描述 投票:-1回答:1

在解析一组本体时,某些文件会给我以下错误,而其他文件则运行良好(请注意,我使用的是OWL API 5.1.6):

uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:1033)
    uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:933)
    uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadImports(OWLOntologyManagerImpl.java:1630)

....

Could not parse JSONLD        org.eclipse.rdf4j.rio.jsonld.JSONLDParser.parse(JSONLDParser.java:110)
    org.semanticweb.owlapi.rio.RioParserImpl.parseDocumentSource(RioParserImpl.java:172)
    org.semanticweb.owlapi.rio.RioParserImpl.parse(RioParserImpl.java:125)

....

Stack trace:
org.eclipse.rdf4j.rio.RDFParseException: unqualified attribute 'class' not allowed [line 3, column 65]        
org.semanticweb.owlapi.rio.RioParserImpl.parse(RioParserImpl.java:138)
    uk.ac.manchester.cs.owl.owlapi.OWLOntologyFactoryImpl.loadOWLOntology(OWLOntologyFactoryImpl.java:193)
    uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.load(OWLOntologyManagerImpl.java:1071)
    uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:1033)
    uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:933)
    uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadImports(OWLOntologyManagerImpl.java:1630)

....

还有很多错误。知道如何解决这个问题吗?


更新:

加载本体的代码片段是:

File file = new File("C:\\vocabs\\" + Ontofile.getName());

OWLOntologyManager m = OWLManager.createOWLOntologyManager();
OWLOntology o;
o = m.loadOntologyFromOntologyDocument(file);
OWLDocumentFormat format = m.getOntologyFormat(o);

OWLOntologyXMLNamespaceManager nsManager = new 
OWLOntologyXMLNamespaceManager(o, format);
java protege owl-api
1个回答
1
投票

此错误表示您正在解析的其中一个本体不是有效的JSON / LD格式。

要解决这个问题,你必须做两件事:

  • 确保正在使用的格式是您期望的格式:OWLAPI,如果未指定格式,将尝试使用所有可用的解析器,直到其中一个解析成功解析本体
  • 如果格式正确,则修复输入数据:在这种情况下,对于JSON / LD,错误在第3行

如果使用的格式不是应该的格式,则需要在代码中指定格式 - 为此,您必须添加用于解析文件的代码片段。

© www.soinside.com 2019 - 2024. All rights reserved.