我正在尝试将一组来自 DBpedia 的 RDF 文件上传到我的 Sesame 存储库中。问题是:对于几乎每个 RDF 文件,Sesame 都会给出以下错误:
'whatever_file_is': 'some_value' was not recognised, and could not be verified, with datatype http://dbpedia.org/datatype/rod [line 30121, column 123]
经过一些研究,我发现 DBpedia 没有在 DBpedia Ontology 中发布数据类型,如下所示(摘自 http://mappings.dbpedia.org/index.php/Datatype:Rod):
Please note: datatypes are not (yet) copied from the DBpedia Mappings Wiki to the DBpedia ontology. They are hard-coded in OntologyDatatypes.scala and were added to the wiki for reference. Adding a datatype in the wiki does not change the ontology and leads to an error messsage for properties that use such a datatype.
所以,如果我是正确的,芝麻在尝试验证这些数据类型时会失败。但我需要上传 RDF 文件。
由于我使用的是Java,所以我尝试了以下代码让芝麻忽略验证:
RepositoryConnection con = repository.getConnection();
Set<RioSetting<?>> set = new HashSet<>();
set.add( BasicParserSettings.VERIFY_DATATYPE_VALUES );
con.getParserConfig().setNonFatalErrors(set);
但是错误继续出现。我还尝试了以下代码:
RepositoryConnection con = repository.getConnection();
con.getParserConfig().addNonFatalError( BasicParserSettings.VERIFY_DATATYPE_VALUES );
但奇怪的是,最后一个给出了一个 java.lang.UnsupportedOperationException
:
Exception in thread "main" java.lang.UnsupportedOperationException
at java.util.AbstractCollection.add(AbstractCollection.java:252)
at org.openrdf.rio.ParserConfig.addNonFatalError(ParserConfig.java:134)
at control.RepositoryControl.loadIntoRepository(RepositoryControl.java:177)
有人知道我应该如何将 DBpedia 中的 RDF 文件上传到 Sesame?
谢谢!
最佳答案
尝试升级到 Sesame 2.7.1。它刚刚与 built-in support for DBPedia datatypes 一起发布.
或者,如果您卡在 2.7.0 上,您应该可以改为这样做:
con.getParserConfig().setNonFatalErrors(new HashSet<RioSetting<?>
(Arrays.asList(BasicParserSettings.VERIFY_DATATYPE_VALUES,
BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES)));
您可能仍会看到有关未知数据类型的消息,但这将是非致命警告而不是错误。
来源:
关于java - 尝试从 DBpedia 上传 RDF 文件时 Sesame 2.7 中的 ParserConfig 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16631063/