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
4
votes
1 answer

Python and rdflib: parsing issues

I am using rdflib (package python-rdflib 2.4.2-3, Python 2.7.5+, Ubuntu 13.10) with immense frustration. I am simply trying to load two NT files into a local triple store. This is the code: from rdflib import Graph graph = Graph('Sleepycat') rt =…
Mulone
  • 3,603
  • 9
  • 47
  • 69
3
votes
0 answers

Changing the join order in a custom RDFLib store

In a project we override the store triples method to generate virtual triples given a subject/predicate or predicate/object pair. And the logic depends on either the subject or object being bound to a real value to work. We are receiving federated…
Jerven
  • 582
  • 3
  • 7
3
votes
1 answer

retrieving object based on its URI using RDFAlchemy and rdflib

I am using RDFAlchemy and rdflib graph for the source of the data, i.e. rdfalchemy.rdfSubject.db. How can I have rdfalchemy map an object if I have its uri? calling the constructor with the uri creates an object but doesn't retrieve values of other…
fadmaa
  • 3,067
  • 3
  • 18
  • 14
3
votes
1 answer

Querying local SPARQL endpoint is very slow

I have setup a local SPARQL endpoint with DBPedia database using Openlink Virtuoso through this guide. Then I tried to query my database through Python with the help of RDFLib and SPARQLWrapper. Problem is the time it take for a query (through…
hainam
  • 33
  • 4
3
votes
4 answers

How to authenticate to Wikimedia Commons Query Service using OAuth in Python?

I am trying to use the Wikimedia Commons Query Service[1] programmatically using Python, but am having trouble authenticating via OAuth 1. Below is a self contained Python example which does not work as expected. The expected behaviour is that a…
3
votes
0 answers

python: parse owl file in manchester syntax to owlready

Is it possible to parse an ontology given in manchester syntax such that it ends up as an owlready ontology-object. This is what I found out so far: Owlready itself can only import "NTriples, RDF/XML or OWL/XML format" (ref1). Ontospy can (among…
cknoll
  • 2,130
  • 4
  • 18
  • 34
3
votes
1 answer

Python / rdflib HTTP server for sparql endpoint

Is there a capability for or example of creating a Sparql HTTP endpoint with rdflib? We would want it to follow the spec and be able to return json and/or csv formats. This would mostly be for POC usage. It would also be possible to use…
CCVirginia
  • 31
  • 4
3
votes
1 answer

import namespace from ".owl" file and use terms in RDFLIB graph

I am creating a graph using rdflib. I want to use some terms from a ".owl" file I have. How can I import this owl file as MyImportedTerminology with rdflib, and access its terms, so that I can do something like this in the graph? g.add((Thing,…
abra
  • 153
  • 2
  • 10
3
votes
2 answers

Printing/Parsing JSON object from RDF query result

I'm trying to parse a result from an SPARQL query from Sesame. I found sample code, the relevant part below, and I'm showing my result below. (response, content) = httplib2.Http().request(endpoint, 'POST', urllib.urlencode(params),…
NealWalters
  • 17,197
  • 42
  • 141
  • 251
3
votes
1 answer

How to convert Pandas DataFrame to RDF (Resource Description Framework)?

I'm looking for a recipe for converting Pandas DataFrames to RDF data in Python. I'm aware of the following Python modules (I know how to Google!), but they do not work for me: rdfpandas pandasrdf Neither seems mature. I have problems with both. In…
3
votes
1 answer

SPARQLWrapper QueryBadFormed error for long SELECT query

Is there a limit on the size of the query you can use with with a SELECT query? I have a long SELECT query (posted below) that keeps throwing a QueryBadFormed error. I have validated the query on sparql.org and I have ran the query on the triple…
Bill
  • 179
  • 8
3
votes
1 answer

printing out individuals for each concept in an ontology using rdflib

I have and ontology written in OWL/RDF(using Protege). This ontology has been already populated with some individuals for each concept. I have ported it in to python using rdflib and FuXi packages. And I can successfully parse my Ontology and put in…
Hossein
  • 40,161
  • 57
  • 141
  • 175
3
votes
0 answers

SPARQL query performance with rdflib-sqlalchemy

I have 7200 or so SKOS.Concept objects created by rdflib-sqlalchemy from parsing a turtle file stored in a Postgres DB. The following SPARQL query takes over 30 seconds to respond with data: SELECT ?subject ?prefLabel WHERE { ?subject rdf:type …
fiacre
  • 1,150
  • 2
  • 9
  • 26
3
votes
1 answer

What does the "identifier" in "Graph" do?

I try to query a database like this: from rdflib import Graph, Literal, URIRef from rdflib.namespace import RDF, SKOS from rdflib.plugins.stores import sparqlstore # define endpoint according to https://www.stardog.com/docs/ endpoint =…
Cleb
  • 25,102
  • 20
  • 116
  • 151
3
votes
1 answer

Python: how to add information from Dbpedia to my graph using rdflib?

I am creating an ontology and I want to add data from dbpedia. For instance, I want to add data regarding Switzerland. This is what I am doing. g = Graph() sparql = SPARQLWrapper("http://dbpedia.org/sparql") query = """ PREFIX dbo: …
emax
  • 6,965
  • 19
  • 74
  • 141