Ich benutze rdflib-jsonld, um einige NoSQL-Daten zu parsen und in Sesame einzufügen. Dies ist der problematische Teil des Codes:rdflib-jsonld erzeugt eine falsche URL, wenn '<' in '@id' verwendet wird
context = {
"@context": {
"isGiven": URIRef('<'+'http://purl.org/net/something#isGiven'+rdfLizerItem['FooByBar']+'>'),
"administeredAs": URIRef('<'+'http://purl.org/net/something#administeredAs'+'>'),
"type":URIRef('<'+'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'+'>'),
}
}
recipient=URIRef('<'+someUrl+rdfLizerItem['FooRecipient']+'>')
jsonldOutputIsAdmin = {"@id": recipient,"isGiven": URIRef('<'+someUrl+ rdfLizerItem['Quantity']+'>')}
print jsonldOutputIsAdmin
g = Graph()
g.parse(data=json.dumps(jsonldOutputIsAdmin), format='json-ld', context=context)
g.close()
for s,p,o in g:
pprint.pprint ((s,p,o))
Das Problem bei der Zugabe von <
und >
an die URL für @id
, die URL des Themas wird der vollständige Pfad zu. Zum Beispiel:
(rdflib.term.URIRef(u'file:///C:/path/to/the/url/<http:/purl.org/net/ontologyName#subject>'),
rdflib.term.URIRef(u'<http://purl.org/net/ontologyName#predicate>'),
rdflib.term.Literal(u'<http://purl.org/net/ontologyName#object>'))
Ich möchte nur die URL im Betreff und nicht den Dateipfad. Was verursacht das Problem und wie kann ich es lösen?
Ich brauche <
und >
, um die Tripel nach Sesame exportieren zu können.