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

Loading RDF data to PostgreSQL Table through RDFLib-SQLAlchemy

I have a large RDF dataset (Geonames dataset: 18GB) in NT format. I would like to load it into a PostgreSQL relational table by using rdflib_sqlalchemy.SQLAlchemy. I know that it is doable (performing sparql query on the rdf data stored in…
Beautiful Mind
  • 5,828
  • 4
  • 23
  • 42
3
votes
0 answers

Check ontology consistency with RDFlib and python

I am using RDF lib with python. Is it there any function that controls if an ontology is inconsistent. < owl:Class rdf:about="http://www.semanticweb.org/ontologies/2016/1/semantic_mapping_domain_model#Chair"> < owl:equivalentClass…
UserK
  • 884
  • 3
  • 17
  • 40
3
votes
1 answer

how to retrieve the namespace of an ontology loaded by rdflib

I created an ontology and now I want to read it using rdflib. the question is how to get the URI (namespace) or the prefix of the loaded graph with out manually inspecting the ontology as below: from rdflib import…
msc87
  • 943
  • 3
  • 17
  • 39
3
votes
1 answer

JSON-LD @id with IRI results in blank node

I have a small JSON file hosted on a local web server with the following content: json_source = {"key1": "azerty", "key2": "qwerty", "key3": "lorem", "key4": "ipsum"} Using the RDFLib library, I'm parsing the JSON, adding some semantics using the…
Brainlock
  • 243
  • 4
  • 11
3
votes
1 answer

How to instantiate an ontology using rdflib?

I have an ontology where I have defined series of classes, subclasses and properties. Now I want to automatically instantiate the ontology with Python code and save it in RDF/XML again and load it in Protege. I have written the following code: def…
msc87
  • 943
  • 3
  • 17
  • 39
3
votes
1 answer

The same query on Sparql gives different results

I read some questions related to my question, like Same sparql not returning same results, but I think is a little different. Consider this query which I submit into http://live.dbpedia.org/sparql (Virtuoso endpoint) and get 34 triples as a result.…
Marcelo
  • 438
  • 5
  • 16
3
votes
2 answers

Text from RDF with RDFlib in Python

I have an rdf file, for example:
Marcelo
  • 438
  • 5
  • 16
3
votes
2 answers

How to parse N3 in RDFlib

I am trying to convert a file into XML using the N3 parser in RDFlib but I am not sure if I am doing it right or even if I have the n3 plugin installed. This is what I have so far: import rdflib from rdflib import URIRef, Graph, Namespace from…
Johnnerz
  • 1,365
  • 4
  • 17
  • 29
3
votes
1 answer

Python rdflib Not Parsing Creative Commons License Information Correctly

I was using rdflib version 3.2.3 and everything was working fine. After upgrading to 4.0.1 I started getting the error: RDFa parsing Error! 'ascii' codec can't decode byte 0xc3 in position 5454: ordinal not in range(128) I tried various way to…
Alex
  • 1,891
  • 3
  • 23
  • 39
3
votes
2 answers

No handlers could be found for logger "rdflib.term"

I am using rdflib-4.0.1 and rdfextras-0.4 in my python modules. I get the following message while loading data into a rdfstore: No handlers could be found for logger "rdflib.term" What is it I am missing??
GJain
  • 5,025
  • 6
  • 48
  • 82
3
votes
1 answer

Refering OWL Class In SPARQL Filter Stament

I have developed an ontology which you can access with the link exist in the code below. The code working fine except FILTER section. If I use equal operator in FILTER, it does not return anything. If I use not equal operator (!=), it does not…
alan turing
  • 463
  • 4
  • 20
3
votes
1 answer

Filtering a n3/turtle file with rdflib and sparql queries

I am trying to filter a turtle file using pyrdf with sparql. But I noticed that sparql queries lose information over the context of the elements. I would like then to re-print the result of the query as a turtle file, is it possible to do this…
ashmikuz
  • 83
  • 5
2
votes
2 answers

How to check that two RDF graphs have the same content?

I'm writing a C library that parses and serializes domain-specific data as RDF/XML. After I parse a file and write it back out again I'd like to be able to check that the content hasn't changed. I could parse everything again, write it out as…
jefdaj
  • 2,025
  • 2
  • 21
  • 33
2
votes
2 answers

Convert anyURI-typed string representations of CURIes to real CURIes or IRIs

I have triples like this, where the object is an anyURI-typed string representation of a CURIe. I would like to construct the triples with the object as a true CURIe or IRI. @prefix source: . @prefix external:…
Mark Miller
  • 3,011
  • 1
  • 14
  • 34
2
votes
1 answer

What's the correct way to code a named graphs where the main graphs contains a triple that refers to the main graph and also displays the named graph?

I'm using Python with the help of the rdflib import to convert a knowledge graph that is in rdf format into a named graph format. I also wanted to add a triple where the named graph is claimed to be said by a source that is within the main graph,…
CJ Acosta
  • 21
  • 1