Search code examples
javardfsemantic-webdbpediasesame

ParserConfig error in Sesame 2.7 when trying to upload RDF files from DBpedia


I am trying to upload into my Sesame repository a set of RDF file coming from DBpedia. The problem is: for almost every RDF file, Sesame give the following error:

'whatever_file_is': 'some_value' was not recognised, and could not be verified, with datatype http://dbpedia.org/datatype/rod [line 30121, column 123]

After some research, I discovered that DBpedia doesn't publish the datatypes in the DBpedia Ontology, as say bellow (extract from 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.

So, if I am correct, the Sesame fails when it tries to verify these datatypes. But I need to upload the RDF files.

As I am using Java, I tried the following code to make Sesame ignore the verification:

RepositoryConnection con = repository.getConnection();

Set<RioSetting<?>> set = new HashSet<>();
set.add( BasicParserSettings.VERIFY_DATATYPE_VALUES );
con.getParserConfig().setNonFatalErrors(set);

But the error continues to appear. I also tried the following code:

RepositoryConnection con = repository.getConnection();
con.getParserConfig().addNonFatalError( BasicParserSettings.VERIFY_DATATYPE_VALUES );

But this last one, strangely, gives a 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)

Someone has any idea of what I should do to get RDF files from DBpedia uploaded into Sesame?

Thanks!


Solution

  • Try upgrading to Sesame 2.7.1. It was just released with built-in support for DBPedia datatypes.

    Or if you're stuck on 2.7.0, you should be able to do this instead:

    con.getParserConfig().setNonFatalErrors(new HashSet<RioSetting<?>
            (Arrays.asList(BasicParserSettings.VERIFY_DATATYPE_VALUES,
            BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES)));
    

    You might still see the message about the unknown data types, but it will be a non-fatal warning instead of an error.

    Source: