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
16
votes
4 answers

How to export graph in RDF file using RDFLib

I'm trying to generate RDF data using RDFLib in Python 3.4. A minimal example: from rdflib import Namespace, URIRef, Graph from rdflib.namespace import RDF, FOAF data = Namespace("http://www.example.org#") g = Graph() g.add( (URIRef(data.Alice),…
Arthur Vaïsse
  • 1,551
  • 1
  • 13
  • 26
10
votes
2 answers

Using SPARQL for limited RDFS and OWL reasoning

What I'm currently using rdflib for creating and managing RDF graphs in Python. RDFlib doesn't do any RDFS or OWL reasoning, though. This leads to results like the following: If I have A rdf:type MyType . MyType rdfs:subClassOf SuperType . and…
Alex
  • 149
  • 1
  • 6
9
votes
4 answers

SPARQL query on the remote remote endpoint RDFLib / Redland

I'm trying to query remote endpoints and get get owl:sameAs mappings, I've tried both RDFLib and Redland but neither worked for me, probably I'm not dealing with namespaces correctly. Here is my attempt in RDFLib: import rdflib …
user52028778
  • 27,164
  • 3
  • 36
  • 42
9
votes
1 answer

how to parse big datasets using RDFLib?

I'm trying to parse several big graphs with RDFLib 3.0, apparently it handles first one and dies on the second (MemoryError)... looks like MySQL is not supported as store anymore, can you please suggest a way to somehow parse those? Traceback (most…
user52028778
  • 27,164
  • 3
  • 36
  • 42
9
votes
1 answer

Apache Jena and Python

I have been working on various relationship extraction models in python and all the relationships are currently saved in dataframes or csv files. Eventually I would like to create an RDF graph. Since I am working in python I was going to create the…
Joe124
  • 189
  • 1
  • 6
9
votes
1 answer

Excluding Blank Nodes from SPARQL query results

I am using RDFLib to query on the Semantic Dicom Ontology. I am querying for owl:Class in the graph constructed from the above ontology. RDFLib returns results which contain blank nodes and I wish to exclude such queries. My query - from rdflib…
Anmol Kagrecha
  • 153
  • 2
  • 10
8
votes
1 answer

Why is rdflib so slow?

I have a large rdf file: size: 470MB number of lines: almost 6 million unique triple subjects: about 650,000 triple amount: about 4,200,000 I loaded the rdf definition into the berkeley db backend of rdflib via: graph =…
8
votes
2 answers

Visualize an RDFLIB Graph in Python

I am new to RDFLIB in python. I found this example of creating a graph on here. What is the simplest way to visualize graph created by this code? import rdflib # Now we create a graph, a representaiton of the ontology g = rdflib.Graph() # Now…
MadProgrammer
  • 423
  • 1
  • 5
  • 17
8
votes
1 answer

Reading a Turtle/N3 RDF File with Python

I'm trying to encode some botanical data in Turtle format, and read this data from Python using RDFLib. However, I'm having trouble, and I'm not sure if it's because my Turtle is malformed or I'm misusing RDFLib. My test data is: @PREFIX rdf:…
Cerin
  • 60,957
  • 96
  • 316
  • 522
8
votes
1 answer

Using Python rdflib: how to include literals in sparql queries?

I can include URIs and variables in my queries, but I can't include literals in my queries. Here, I have some code which successfully reads an RDF file, finds all the RDF triples with skos:prefLabels, counts them, and then identifies a couple of…
Diana Bental
  • 83
  • 1
  • 4
7
votes
2 answers

Writing RDF/XML file from rdf Triples in rdflib

I have got rdf triples with me, now I am interested in generating RDF/XML file using rdflib in Python. Could you please give me some sample code to start. Thanks
Muhammad Imran
  • 1,051
  • 1
  • 9
  • 6
7
votes
2 answers

How to run IN and NOT IN SPARQL statements in python rdflib to remove the intersection of two graphs

I'm trying to use the IN and NOT IN statements (that were if I understand correctly, introduced in SPARQL 1.1) on the python implementation of SPARQL (now in rdfextras) but it seems that the syntax is not recognised. Let's consider two sets (A and…
Alexis Métaireau
  • 10,767
  • 5
  • 24
  • 34
7
votes
2 answers

error: invalid command 'build_sphinx'

how can I install the documentation for rdflib in mac osx 10.10.1 python 2.7.9? I have followed the instructions as outlined in 1 and I get error: invalid command 'build_sphinx' the documentation does not install. the library rdflib works well, I…
7
votes
1 answer

Determining Hypernym or Hyponym using wordnet nltk

I want to check for the hypernyms/hyponym relation between two words (given by the user) which means any of them can be hypernym of other or it can also be the case that there is no hypernym relation between the two.Can I use path_similarity for…
ankita singh
  • 115
  • 1
  • 1
  • 9
7
votes
2 answers

SPARQL Query gives unexpected result

I hope someone can help me on this probably totally easy-to-solve problem: I want to run a SPARQL query against the following RDF (noted in N3, the RDF/XMl sits here). This is the desription of a journal article and descriptions of the journal,…
fab
  • 71
  • 1
1
2 3
29 30