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
2
votes
0 answers

rdflib and NCName errors

Running into errors due to NCName convention not being respected in a RDF/XML file. It is pretty clear that it isn't being respected and it is found in many spots. Is there any way around this as I don't have any control on the output file? The…
2
votes
1 answer

ASK SPARQL queries in rdflib

I'm trying to learn SPARQL and I'm using python's rdflib to train. I've done a few tries, but any ASK query always seems to give me back a True result. For instance, i tried the following: #!/usr/bin/python # -*- coding: utf-8 -*- import…
user3523375
  • 153
  • 3
  • 12
2
votes
1 answer

SPARQL BIND breaks VALUES?

I was using VALUES in many SPARQL queries recently, only to realize that in one of them I was not getting what I was expecting. Here is a simple case: @prefix ns: . a ns:Document ; ns:A5000 "00003381" ; ns:A5080…
2
votes
1 answer

RDFLib: Remove namespace from a URIRef resource

I have the following resource: http://test.com/domainOnt/email#plans@plan.com As in RDFLib, when you search for this in a graph, it returns a URIRef object. I would like to remove the namespace from the object so that it becomes plans@plan.com any…
user1894963
  • 635
  • 3
  • 11
  • 18
2
votes
1 answer

Getting all relations in DB by using rdflib

Lets say i have collection of some kind in mongoDB, and i want to create graph with ALL possible relations using rdflib. For example if I have 3 entries in my DB: FIRST{color:red, name:Ben, age: 29} SECOND{color :blue ,name:David,…
Farseer
  • 4,036
  • 3
  • 42
  • 61
2
votes
1 answer

rdflib graph not updated. Why?

I am trying to understand this behavior. It's definitely not what I expect. I have two programs, one reader, and one writer. The reader opens a RDFlib graph store, then performs a query every 2 seconds import rdflib import random from rdflib import…
Stefano Borini
  • 138,652
  • 96
  • 297
  • 431
2
votes
2 answers

Adding RDF text to graph RDFlib

How do I add RDF text that has been assigned to a variable (this text has also been validated and is correct RDF) to a graph in RDFlib? I have a variable assigned to a bunch of text in RDf format like below: block = '''
Johnnerz
  • 1,365
  • 4
  • 17
  • 29
2
votes
2 answers

Error in serializing Notation3 file into RDFXML format in python

So I have a Notation3 file that looks like this: @prefix wn: . @prefix lemon: . @prefix lexinfo: . :lexicon a lemon:Lexicon ; …
Johnnerz
  • 1,365
  • 4
  • 17
  • 29
2
votes
3 answers

SPARQL query using a local RDF store

I am trying to create a SPARQL query using a local RDF graph. But its not working. I have included my code below is my code. I have two classes called Student and University. The student class has two attributes (enrolledOn and studiesAt). The…
Harith
  • 21
  • 3
2
votes
1 answer

Getting class of an individual, using SPARQL

I want to get the class which an individual belongs to. In more detail, I want to pass a parameter to a method which is an individual using python (using rdflib), method should return class of an individual which it belongs to. For example: I have a…
alan turing
  • 463
  • 4
  • 20
2
votes
2 answers

Error in using sparql DELETE query using rdflib python

I am trying to DELETE triples from RDF graph using rdflib library of python, but not succeeding in doing so. My query is the follwong learned from http://www.w3.org/TR/sparql11-update/#delete . plugin.register( 'sparql', rdflib.query.Processor, …
imran
  • 199
  • 3
  • 11
2
votes
2 answers

Database structure of a triple store?

I want to use RDF / triples in my Symfony2 project in order to organize things (in my case it is Tags). I would see something like this : ENTITY TAG <-------------- TAG_TAG --------------> ASSOCIATION_TYPE ^ | …
Creasixtine
  • 740
  • 3
  • 11
  • 33
1
vote
1 answer

How to determine or filter datatype of a rdflib literal?

I haven't used rdflib in a while and am writing some trivial code based on https://rdflib.readthedocs.io/en/stable/intro_to_graphs.html#basic-triple-matching like from rdflib import Graph graph = Graph() ttl_input =…
Mark Miller
  • 3,011
  • 1
  • 14
  • 34
1
vote
1 answer

SPARQL Namespace conflict while querying

I'm quite puzzled by the behavior of my endpoint, nor by the processing of the request. The basic RDFS namespace seems to clash with another definition while querying, resulting in an error when declaring the prefix and a normal output when omitting…
1
vote
0 answers

Why doesn't the 'HAVING' function work in RdfLib SPARQL queries?

I'm trying to use the HAVING funtion in a SPARQL query. While the query works fine in Protege, it does not return any result when I use it in a query in the rdflib package(it does not raise an error either). Is it not supported in this package? or…
Samah K
  • 23
  • 3