这是我填充和解析rdflib图的代码:
context = {
"@context": {
"isGiven": URIRef('<'+'https://w3id.org/ontology#isGiven'+rdfLizerItem['ProductByCategory']+'>'),
"givenAs": URIRef('<'+'https://w3id.org/ontology#givenAs'+'>'),
"type":URIRef('<'+'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'+'>'),
# "recipient":URIRef('<'+varOnt+rdfLizerItem['ProductRecipient']+'>'),
"@base": '.'
}
}
recipient=URIRef('<https://w3id.org/ontology#'+rdfLizerItem['ProductRecipient']+'>')
dose = URIRef('<'+varOnt + rdfLizerItem['Dose']+'>')
productByCategory = URIRef('<'+varOnt+rdfLizerItem['ProductByCategory']+'>')
dummyBrand = URIRef('<'+varOnt+rdfLizerItem['ProductByCategory']+'BrandGivenTo'+rdfLizerItem['ProductRecipient']+'>')
jsonldOutputIsGiven = {"@id": recipient, "isGiven":dose}
jsonldOutputGivenAs = {"@id":dummyBrand,"type":productByCategory,"givenAs": scoop}
# graph1 = Graph()
graph1.parse(data=json.dumps(jsonldOutputIsGiven), format='json-ld', context=context)
graph1.parse(data=json.dumps(jsonldOutputGivenAs), format='json-ld', context=context)
graph1.close()
for s,p,o in graph1:
pprint.pprint((s,p,o))
在图表的输出中,主题在网址中缺少/
。例如:
(rdflib.term.URIRef(u'<https:/w3id.org/ontology#ProductBrandGivenToeSomeone>'),
rdflib.term.URIRef(u'<https://w3id.org/ontology#givenAs>'),
rdflib.term.Literal(u'<https://w3id.org/ontology#scoopSome>'))
我需要做些什么来确保网址格式正确?