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

Printing the broader and narrower concepts against the captured URI REF

I am having difficulty in printing the SKOS broader and narrower concepts against my URIRef (i.e. the output of the SPAQRL query). I want to print the Broader and Narrowers concepts against the captured URI REF (i.e. Biomass). The file which i am…
Beginner
  • 37
  • 8
0
votes
1 answer

Are keys with ":" (colon) allowed in the "@context" of a json-ld graph?

Are json-ld contexts allowed to have ":" in their keys? For example, is the following a valid json-ld document? { "@context": { "abc:def": "http://abc-def.com/" }, "@graph": [ { "abc:def": "something" } ] } I couldn't find…
Cnoor0171
  • 368
  • 3
  • 12
0
votes
1 answer

SPARQL Query not returning depth

I have the following SPARQL Query: SELECT ?depthClass (count(?mid)-1 as ?depth) WHERE { { SELECT ?root WHERE { ?root a owl:Class FILTER NOT EXISTS { ?root rdfs:subClassOf…
Ajay_C
  • 1
  • 1
0
votes
1 answer

print rdflib.Graph using serialize() in the same layout

I'm having the following problem when using rdflib serialize() method to print the graph. The layout changes from the original file used to create the graph. The code is as follows from rdflib import Graph mapping_graph =…
Alex
  • 21
  • 5
0
votes
1 answer

Saving rdflib.Graph into a dictionary

I would like to save an rdflib.Graph into the session dictionary within my Flask application as I need to access it from other route functions. The code is as follows. from rdflib import Graph from flask import Flask, session import os app =…
Alex
  • 21
  • 5
0
votes
1 answer

Is there a way to configure rdflib serializer to use a specific UTC date format?

I have a server that rejects a triple using the UTC offset syntax: rtc_cm:due "2020-09-08T14:30:00+00:00"^^xsd:dateTime (Turtle) but succeeds using the Z suffix: rtc_cm:due "2020-09-08T14:30:00Z"^^xsd:dateTime (Turtle) Is there a way to configure…
0
votes
0 answers

MeSH (Medical Subjects Heading) Dataset (mesh.nt) not working in RDFLib Python

I am trying to figure out the loading time, traversal time, and queries response time of RDFLib using MeSH dataset in N-Triple format. I am trying to execute the queries for two days but no luck. Here is the code: import time from rdflib import…
bamboat_3
  • 11
  • 1
  • 6
0
votes
0 answers

SPARQL query to find line number of triple

I am currently building a framework using a combination of SPARQL queries with Pythons rdflib package. This framework is designed to identify triples which don't meet quality requirements. As you may know, RDF files can contain a large number of…
Alex R
  • 31
  • 7
0
votes
0 answers

How to use rdflib to represent Geometrical points in RDF data?

I am using rdflib to convert text files into n3 files for the purpose of saving bus station locations (GTFS).For example if we had latitude=8.0, longitude=5.0, the literal would be: "POINT(5.0…
Looper
  • 106
  • 8
0
votes
0 answers

Load RDF file to OrientDB using Apache tinkerpop gremlin

I'm using OrientDB with gremlin server (https://s3.us-east-2.amazonaws.com/orientdb3/releases/3.1.1/orientdb-tp3-3.1.1.zip) and my requirement is to load a RDF file to orientDB. I'm using rdflib python library to act as a middleware to parse and…
0
votes
1 answer

rdflib : ParseException: Expected {SelectQuery | ConstructQuery | DescribeQuery | AskQuery}, found 's' (at char 17), (line:2, col:17)

Working on several SPARQL queries that works, we are facing an issue with the rdflib library, with queries containing projection with str function. Here is an example of code on which the parser fail : query = """ SELECT DISTINCT str(?s) WHERE { ?s…
Max_BZH
  • 1
  • 1
0
votes
1 answer

How to check isomorphism across subgraphs

I want to check for isomorphism across subgraphs in a larger dataset. Is there a way to do this in rdflib without breaking the graph into multiple variables, like in the example from rdflib docs: g1 = Graph().parse(format='n3', data=''' @prefix…
Alex
  • 169
  • 1
  • 1
  • 8
0
votes
1 answer

How do I describe a temperature with min/max values in RDFlib with schema.org?

I'm using schema.org to create a RDF/XML file using RDFlib in Python, and am trying to nest elements into a PropertyValue element like so, but it's not working... g.add((p, n.PropertyValue, (p, n.minValue, Literal(130.15)))) I'm trying to end up…
MA40
  • 61
  • 1
  • 8
0
votes
1 answer

Providing the @type in the @context for a value

I have the following json-ld document: { "@context": { "ex": "http://example.com/", "yyyy": "ex:yyyy", "name": "ex:name", "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#", "rdfs":…
James Hudson
  • 844
  • 6
  • 19
0
votes
1 answer

How to update parsed data in rdflib ConjunctiveGraphs?

I am merging RDF data from various remote sources using ConsecutiveGraph.parse(). Now I would like to have a way to update the data of individual sources, without affecting the other ones and the relations between them. The triples from the various…
Torsten Knodt
  • 477
  • 1
  • 5
  • 20