I'm trying to parse a turtle-formatted data file using RDFlib v4.2.2 in Python v3.6.5, running on OS X 10.14.3 Mojave. Based on the initial error messages, I figured out that the turtle file is missing a vocabulary URI prefix: @prefix xsd: <http://www.w3.org/2001/XMLSchema#>
.
If I add this one line to the header of the file, it works as expected. But it would be nice to accomplish this without editing the data file, since it can be updated from time to time by the source. Being a novice at things RDF and Turtle, I scanned the RDFlib documentation and decided that binding a prefix was what I wanted:
from rdflib import Graph
g = Graph()
g.namespace_manager.bind('prefix', 'xsd:http://www.w3.org/2001/XMLSchema#')
g.parse( 'currency.ttl', format='turtle')
But, no joy. If it's helpful, here is the header and one sample turtle from the file, which describes different currencies, taken from the Thomson Reuters Open PermID project:
@prefix tr-common: <http://permid.org/ontology/common/> .
@prefix tr-currency: <http://permid.org/ontology/currency/> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
<https://permid.org/1-500191>
a tr-currency:Currency ;
tr-common:hasPermId "500191"^^xsd:string ;
tr-currency:decimalPlaces "0"^^xsd:decimal ;
tr-currency:isCurrencyOf <http://sws.geonames.org/1835841> ;
tr-currency:isISOHistorical false ;
tr-currency:isPrimaryCurrencyOf <http://sws.geonames.org/1835841> ;
tr-currency:iso4217 "KRW"^^xsd:string ;
tr-currency:iso4217Numeric "410"^^xsd:string ;
skos:prefLabel "Korean (South) Won" .
Is it possible to supplement the prefix URI's contained in the turtle file, and if so, how?
I noticed that the missing vocabulary, XSD, is a integral part of the Turtle grammar specification. I wonder if explicitly declaring it is perhaps optional in some implementations?