Questions tagged [rdflib]

RDFLib is a Python library for working with RDF. It supports parsers and serializers for different syntaxes (RDF/XML, N3, N-Triples, Turtle, TriX and RDFa) as well of remote and local SPARQL queries. Please do not use this tag for rdflib.js.

Resources

Please do not confuse the RDFLib Python library with the rdflib.js Javascript library.

439 questions
0
votes
1 answer

Cannot use property paths with rdflib

I am trying to use property paths with rdflib 4.2.1. With the following class hierarchy: Clothing Women TopsWomen TShirtWomen an instance (:aShirt) of type TShirtWomen, and the following query prefix rdfs:…
Jay
  • 127
  • 9
0
votes
0 answers

python sequence item 0: expected str instance, NoneType found

I'm trying to convert a local .xml file to .ttl and I used this code: import rdflib g=rdflib.Graph() g.parse("C:\\Users\\Username\\Desktop\\public-12T23.xml",format='xml') print (g.serialize(format='turtle')) and I got this error TypeError …
Saeid Hedayati
  • 83
  • 1
  • 3
  • 12
0
votes
1 answer

Why while querying ontologies we have to load the ontology, also provide its namespace?

I wonder why we have to load an ontology, also provide its namespace while querying it? Why loading the ontology is not enough? To understand my question better, here is a sample code: g = rdflib.Graph() g.parse('ppp.owl', format='turtle') ppp =…
RFAI
  • 459
  • 4
  • 17
0
votes
1 answer

Filter 1 to n relation between subject and objects in RDF graph

I want somehow in python in RDF graph with RDFlib, to filter only the predicates that make 1:n relation between subjects and objects. Could anyone help me with this?
Saeid Hedayati
  • 83
  • 1
  • 3
  • 12
0
votes
1 answer

Star subgraph pattern finding in SPARQL

I have a collection of RDF triples like following. id#7289587 ex:getInfectedBy id#7748320 id#7694711 ex:getInfectedBy id#7748320 id#7748322 ex:getInfectedBy id#7748320 id#7748887 ex:getInfectedBy id#7748320 id#7746679 …
Beautiful Mind
  • 5,828
  • 4
  • 23
  • 42
0
votes
0 answers

Why the language tag of the labels are not extracted

I am using rdflib, to query series of rdf files in which I know that the names have a language tag (when I query in a sparql endpoint), this is a snapshot of my data: but when I parse the rdf file in python and extract the 'name' value I only get…
DMD
  • 103
  • 1
  • 8
0
votes
1 answer

SPARQL query with Turtle file (Public data source)

I am new to Turtle format files and querying them with SPARQL. So I have many questions to be solved, I hope you can help me! I have a file called equipamentsCURT3.ttl and contains the following: @prefix rdf:…
cmc_carlos
  • 123
  • 1
  • 1
  • 8
0
votes
0 answers

Storing different graphs created by RDFlib that uses the same Bnodes

I created different graphs using RDFLib in python which share the same Bnodes. Each BNode has a specific name. I am trying now to store all the graphs in one graph using 4store and http4store. The problem I am facing is that after adding a graph to…
TJR
  • 15
  • 5
0
votes
1 answer

Syntax of SPARQL query in Python to query ttl file

I am trying to query a (originally .ttl) file with the RDFLib in Python. An extract from the file is shown below. http://id.vlaanderen.be/statistieken/dq/kubus-kadaster/observatie/0/0/0#id a qb:Observation ; qb:dataSet…
Bert Carremans
  • 1,623
  • 4
  • 23
  • 47
0
votes
0 answers

Python RDFLib plugin printed unread json

I am trying to reproduce the example code from https://github.com/RDFLib/rdflib-jsonld as below: from rdflib import Graph, plugin from rdflib.serializer import Serializer testrdf = ''' @prefix dc:
suesalito
  • 3
  • 1
0
votes
0 answers

Return Variable Name from sparql query in rdflib python

I am starting out learning about SPARQL and rdflib. I stumbled upon this simple example online: import rdflib # Now we create a graph, a representaiton of the ontology g = rdflib.Graph() # Now define the key words that we will use (the edge weights…
MadProgrammer
  • 423
  • 1
  • 5
  • 17
0
votes
1 answer

Using arabic characters in sparql in python?

I developed my own ontology in arabic, and now i wanna do some sparql request using rdflib and sparql. The problem is when i make a request without using the Arabic language on my ontology i got answers without problems ,but when i want to do a…
Mehdi
  • 21
  • 1
  • 6
0
votes
0 answers

How to insert/update/delete form RDF Sesame using python rdflib?

I'm kind of new in using sesame and I've build a python client application in order to query sesame opendrdf. I've managed to retrieve data, but I can't do the write operations: insert, update and delete. I have a graph which has the name "graph"…
Amy
  • 11
  • 3
0
votes
0 answers

How to replace a namedIndivdual in a prepared query in RDFLib

I have the following code which works: for ref_roundaboutID, ref_roundaboutInfo in ref_roundabouts_dict.iteritems(): print ref_roundaboutID, ref_roundaboutInfo ref_RaURI = ref_roundaboutInfo["URI"] query = "SELECT distinct ?p ?a ?FID ?b …
msc87
  • 943
  • 3
  • 17
  • 39
0
votes
1 answer

Difference between graph.add() and dataset.add() in RDFLib library, python

My question is: what is the difference between dataset.add() and graph.add() in rdflib for python. I was working under the assumption that graph.add was used for the object type properties and dataset.add was for the data type properties. However I…
A.A.
  • 127
  • 1
  • 10