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

Making changes to a ntriples file with python

Scenario: I just got my hands on a huge ntriples file (6.5gb uncompressed). I am trying to open it and perform some operations (such as cleaning some of the data that it contains). Issue: I haven't been able to check the contents of this file.…
DGMS89
  • 1,507
  • 6
  • 29
  • 60
0
votes
1 answer

Node-red lost connection to the server with new node

I have to connect to Sparql endpoint and query RDF via Node-red. I found an add-on node called node-red-contrib-sparql which enables that. I am able to install the node. I downloaded python and install required libraries for nodes to work. However,…
Laura
  • 1
0
votes
0 answers

Querying the shared nodes in a RDF graph

I have a graph of RDF data, that is the result of a SPARQL query in rdflib, but this question is valid just on any endpoint too. The graph looks like the picture below. I want to find a way to query the nodes that are shared between two clusters.…
0
votes
0 answers

install 'rdflib' on online jupterlab over browser

I'm new to jupyterlab, I run it on my browser. While I'm adding Sparql code, I tried to import rdflib; However, it shows me an error saying ModuleNotFoundError: No module named 'rdflib'. I need help of how to make rdflib works on online JupyterLab
Medhat Ahmed
  • 21
  • 1
  • 3
0
votes
0 answers

Searching an xml file with rdflib and sparql

I'm struggling to understand how sparkle query's work. I have a following xml…
Ninjasoup
  • 173
  • 1
  • 12
0
votes
1 answer

Owlready2 parsing error when calling sync_reasoner

The ontology was created using protege and populated data from database using the owlready2 library. Now this line is giving this error: sync_reasoner(my_world) This is the error I have encountered: Could not parse ontology. Either a suitable…
Tharindu
  • 386
  • 3
  • 17
0
votes
1 answer

Ontology: Create class connections in an ontology

I have an ontology (a taxonomy, with classes only; no individuals) like this: Owl:Thing Parts Jackfruit Jackfruit_flower Grape Plant Jackfruit_tree Grapevine I want to create a relation to connect…
OntoUser
  • 1
  • 1
0
votes
2 answers

How to get graph's namespaces in rdflib

I've loaded an RDF file in Python, using rdflib: g = rdflib.Graph() g.parse ( "foaf_ex.rdf" ) the *.rdf defines a number of prefix/namespace pairs (e.g., foaf:) and I know they come into g because they're still there when I print g.serialize(). My…
zakmck
  • 2,715
  • 1
  • 37
  • 53
0
votes
2 answers

SPARQL Query to Identify Predicates from One of Many Graphs

I have created an ontology by grouping together many ontologies. I want to use SPARQL to identify all middle terms (relationships) from one ontology from the group ontology. The following approach only produces a pyparsing error. g =…
mac389
  • 3,004
  • 5
  • 38
  • 62
0
votes
1 answer

RDFlib query not working

I wrote a Python script that should be able to run through a list of dbpedia URI's and run a query on them. However, for some reason I get an error on qres = g.query(query) when I run this code. Does anyone know why this happens and how I could…
Knarf
  • 137
  • 1
  • 12
0
votes
1 answer

Query regarding SPARQL with a RDF file using CIDOC-CRM ontology

I'm a beginner in Apache Spark, SPARQL, I'm trying to make some queries on an RDF file using CIDOC-CRM ontology, I execute this SPARQL query but It never turn with a result from rdflib import Graph g = Graph() g.parse("data.rdf") res = g.query( …
Yardi
  • 101
  • 8
0
votes
0 answers

Error parsing N-Triple file using RDFlib

I am trying the load the triples from a Linked data dump into my local triplestore using RDFlib. An example triple in my file: "Some detail about the subject"@EN . Snippet of the code: …
RDangol
  • 179
  • 9
0
votes
1 answer

RDFlib count not working in SPARQL query

I am exploring python based library 'RDFlib' with native store (Sleepycat). A basic "select * ..." query works fine but COUNT does not seem to work. Here is my code: from rdflib import ConjunctiveGraph, Namespace, Literal path =…
RDangol
  • 179
  • 9
0
votes
0 answers

Parsing SPARQL UPDATE queries with rdflib

I am trying to programmatically analyze a SPARQL 1.1 UPDATE query using rdflib. Using the following (Python 3.5) code: from rdflib.plugins.sparql.parser import parseUpdate from pprint import pprint qs = '''DELETE { <> a ,…
user3758232
  • 758
  • 5
  • 19
0
votes
0 answers

Failure adding graph to remote SPARQL store

I am trying to add triples to a remote SPARQL repository, using Python and rdflib 4.2.2. Adding statement-wise works: gsu = rdflib.plugins.stores.sparqlstore.SPARQLUpdateStore(sparql_endpoint, update_endpoint, bNodeAsURI=False, sparql11=True,…
Jay
  • 127
  • 9