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

How to store Polygon Coordinates as WKT Literal Values using RDFLIB?

I am working on GEOSPARQL queries. And I want to store Polygon Coordinates as wktLiteral values using RDF Graph (RDFLIB python). Currently I am doing that using the below code. GEO = Namespace("http://www.opengis.net/ont/geosparql#") if name ==…
Manoj Deshpande
  • 311
  • 2
  • 18
0
votes
1 answer

rdflib invalid remote context when testing on local sever

I am trying to test different contexts applied to json file. I have created a very simple context file (named mycontext.json) on my local machine (a 2019 MacPro) with the contents: { "name": "http://example.com#name", "age":…
Bill
  • 179
  • 8
0
votes
1 answer

Protégé: Différent results between DL Query and SPARQL Query

Here is a small ontology called wildlife.owl, created by Protégé, in which I have classes animal, carnivore, herbivore, lion, giraffe, and individuals Léo (a lion), Gigi (a giraffe) and Giginou (also a giraffe). In the ontology I only declare that…
yannis
  • 819
  • 1
  • 9
  • 26
0
votes
1 answer

How to relabel nodes in a rdf(.ttl) graph in visual presentation in python?

I want to get a visual presentation of a rdf(.ttl) graph. I am using this code(python): # print the ttl sources as a graph def nt_to_graph(rel_path): g = Graph() g.parse(rel_path, format="ttl") g.bind("food", "http:/food#") G =…
eytaniva
  • 11
  • 1
0
votes
2 answers

same python code works different in FLASK and CLI script

I'm running code in a python script and code in a flask api. The problem is to add rdf triples to an rdflib Graph. If i run it in command line script parsed by interpreter it works. If i run the same code in a flask api it ignores some logic. The…
Nja
  • 439
  • 6
  • 17
0
votes
1 answer

rdflib query sparql cause parsing error with FILTER key

I'm trying to run a SPARQL query against a graph with rdflib. It works well if i didn't use FILTER else it cause error on parsing the string to a query. i'm using PYTHON 2.7. Looking at other people query i cannot see any syntax error. Here the…
Nja
  • 439
  • 6
  • 17
0
votes
2 answers

How to write Sparql query for the following result?

[![SPARQL Query Details][2]][2] How should I write SPARQL query to get the details from node2 : URI for node2 is same in both the graphs and URI for node 1 is different. Thank you in advance. as such, I need below details. node2 def hasID…
Manoj Deshpande
  • 311
  • 2
  • 18
0
votes
1 answer

How to properly patch with ModelSerializer?

I'm trying to .save() my data in database. But I get an error {'Hero_id':[ErrorDetail]}. Models.py: class Hero(models.Model): Hero_id = models.IntegerField(auto_created=True,…
Denzel
  • 359
  • 4
  • 12
0
votes
1 answer

Store add_graph appears to do nothing with rdflib and Fuseki

I have a Fuseki endpoint and want to use the python rdflib library to add graphs to it. I connect to the Fuseki server as follows: import rdflib from rdflib import Graph, Literal, URIRef from rdflib.plugins.stores import sparqlstore query_endpoint…
user2302244
  • 843
  • 2
  • 11
  • 27
0
votes
1 answer

Adding triples from a list to graph using python's rdflib framework

I am trying to add triples to a Graph using python's rdflib package. The relations are provided as a list (a particular column in a dataframe) sampleRelations = ['similarTo', 'brotherOf', 'capitalOf'] g = Graph() # general relations gen =…
Betafish
  • 1,212
  • 3
  • 20
  • 45
0
votes
1 answer

how to pattern match triples using rdflib without using SPARQL

I want to pattern match triples of an existing RDF graph. The triples() function of the RDFLib module looks like it could do the job, but I cant get it to work. Can someone provide an example? Consider the following graph. @prefix ex:…
user0221441
  • 368
  • 4
  • 11
0
votes
0 answers

rdb2rdf using rdflib but open() does not work

i am trying to convert relational db to rdf using rdflib , i tried code you can find it in this link https://pypi.org/project/rdb2rdf/ but does not work. i am using SQL server instead of PostgreSQL. after open() , i print length of graph and give me…
alaa seb
  • 1
  • 2
0
votes
1 answer

how to search for jobs using semantic search and ontology using python?

i'm building a simple online semantic search engine to find jobs and i found a simple program that reads a local owl file but i want it to be online to fined jobs and employers using the semantic web and linked data from owlready2 import * class…
Mosa Abbas
  • 139
  • 1
  • 1
  • 16
0
votes
0 answers

Properties of RDF subjects

I have an nt file with three tubles subject, predicate, object Now I want to group for each subject on its predicates. For example if I have Then the output will be s p1, p2, p3 using python rdflib any…
0
votes
1 answer

How to append .ttl file in python rdflib

I am working by using rdflib python library for .ttl file processing. I have some triples in the .ttl file but I want to append (update) the file by adding new triples to the existing .ttl file using python rdflib library. For example: file1.ttl…
Shahi Dost
  • 21
  • 4