Newest 'rdflib' Questions (original) (raw)

0 votes

0 answers

11 views

Write a custom function for "evalFilter" to get its intermediate values

RDFLib supports rdflib.plugins.sparql.CUSTOM_EVALS so that we can define our own method when a query is executed. I want to extract all the intermediate values while "evalFilter" is ...

Smart Hunter's user avatar

asked Apr 5 at 9:46

0 votes

1 answer

39 views

rdflib removes duplicate values for a jsonld property which is an array of values

I have a jsonld representation of triples : {"@id": "some-id", "@type": "Row", "attendance": 74439, "...

Rishabhg's user avatar

asked Mar 19 at 13:02

How to add a list as an attribute value when using Neo4j's rdflib parser

Suppose I have an RDF .ttl file that includes: https://example/Product\_1 http://www.w3.org/ns/dcat#keyword "health". https://example/Product\_1 <http://www.w3.org/...

Bahar's user avatar

asked Nov 6, 2024 at 19:23

rdflib 7.1.1 namespace bindings not being serialized in turtle file

I am trying to export a knowledge graph as a turtle file, but for some reason my prefixes don't seem to make it into the turtle file (or at least not all of them). Minimum reproducable code (written ...

Bradley Sutliff's user avatar

asked Nov 1, 2024 at 17:43

2 votes

1 answer

60 views

Federated Query between two RDFlib graphs

I have two local knowledge graphs in the form of turtle files. Let's say they look something like: File1 - people.ttl Bob a person ; feeds cat-1 ; trains dog-1 ; owns house-1 . File 2 - ...

Bradley Sutliff's user avatar

asked Oct 23, 2024 at 19:52

0 votes

1 answer

58 views

rdflib converting a complex CSV to a Graph - chained objects

I'm fairly new to OWL and RDFlib, so my apologies if any of my terminology is off. I have a CSV that I'd like to convert into a knowledge graph, where each row becomes a sort of top level subject, and ...

Bradley Sutliff's user avatar

asked Oct 21, 2024 at 21:51

0 votes

2 answers

56 views

Significance of IDs Starting with "N" in RDF Data Using RDFLib

I'm working with RDF data stored in a PostgreSQL database that was added using the RDFLib-SQLAlchemy library. While querying the asserted_statements table using SQL, I noticed that some objects and ...

Karthik Jain's user avatar

asked Sep 13, 2024 at 10:28

SPARQL query returns 0 results when querying specific value in array

I am new to RDF and SPARQL, so i want to list all the Properties that https://schema.org/ListItem can have for example. This is the turtle file for https://schema.org/version/latest/schemaorg-current-...

Neca's user avatar

asked Aug 15, 2024 at 13:26

0 votes

0 answers

121 views

How to generate a turtle format file of rdf-star using rdflib?

See example 19 of w3 rdf1.2 specification: PREFIX : http://www.example.org/ :employee38 :familyName "Smith" . << :employee38 :jobTitle "Assistant Designer" >>...

lix joy's user avatar

asked Jun 1, 2024 at 6:05

0 votes

1 answer

95 views

rdflib not parsing rdf file

im trying to open an rdf file using rdflib in python but it is not working here are my codes: import rdflib g = rdflib.Graph g.parse("C:\Users\UserName\Documents\jazzmusic.rdf") and got ...

randomcluelessperson's user avatar

asked May 23, 2024 at 15:48

0 votes

1 answer

81 views

Validating RDF against a SHACL, Error Message: Node ex:**** does not contain a value in the set: ['Literal("false" = False, datatype=xsd:boolean)']

I am trying to validate an RDF file against a SHACL graph. I could not post the files here because they are huge-in-size, but I pasted down sample parts. RDF: ex:GUID_5ACC3D0F-28A1-4E83-A0F1-...

user15052024's user avatar

asked May 15, 2024 at 12:02

0 votes

0 answers

35 views

Deductive closure of the disjointness axioms

I have an OWL file and, I am interested only in the disjointness axioms in this ontology. I can extract the classes that are disjoint (with RDFLib library). However, I want the closure of the disjoint ...

Adel's user avatar

asked May 10, 2024 at 8:43

1 vote

0 answers

124 views

RDFlib serlialization in json-ld without blank node ids

To construct the graph with rdflib I use blank nodes, the IDs of which I do not want to serialize. I To construct a graph: from rdflib import URIRef, Graph, XSD, BNode, Literal, RDF g = Graph() bnode ...

Nora's user avatar

asked Mar 20, 2024 at 15:25

How to extract the language tags from Turtle RDF data?

I want to extract the language tags. I am unable to access the language tags and getting an error that "@" is not used in queries. This is my data: @prefix msterms: <http://materials....

PrincessIris's user avatar

asked Mar 13, 2024 at 14:32

0 votes

1 answer

89 views

Python - rdflib - json-ld - why does it not parse the nested triples

I have the following code, parsing the JSON-ld file below. However, it only outputs the top-level triples and not the other, such as the name of the WebPage from rdflib import Dataset from rdflib....

Kaj Kandler's user avatar

asked Mar 10, 2024 at 21:15

0 votes

2 answers

264 views

Load an ontology in R

I would like to find which values from a list exist in a specific ontology using bert map algorithm. One of the first steps is to load the ontology in order to use it in the process. As I am newbie in ...

Eleni Kalaitzi's user avatar

asked Mar 6, 2024 at 13:48

Weird behavior on LIMIT and OFFSET when querying DBPedia

I'm querying DBPedia's Virtuoso endpoint via RDFLib in order to get all entities of type dbo:Politician with no other occupation than that, and I have noticed that the results I get when performing ...

Lightsong's user avatar

asked Mar 6, 2024 at 13:32

How to get the lowest subclass of an instances in an rdf graph?

Imagine a ontology with several classes and subclasses. Now i use another namespace to instantiate for example a MathTeacher. MathTheacher is a subclass of Teacher and Teacher a subclass of Job. Now i ...

Max Berktold's user avatar

asked Jan 14, 2024 at 16:12

create custom_function in rdflib

I'm trying to create a custom function in rdflib in Python to call from a SPARQL query. I created this simple example that should return "test". It does not give an error. It just returns ...

Rick Companje's user avatar

asked Jan 5, 2024 at 9:09

1 vote

1 answer

107 views

SPARQL OPTIONAL with BIND not working in RDFlib

I tried the following query and found that it works in rdf4j and not in rdflib. After doing some brute force, I found out that the query does not behave as expected only when there is a BIND within ...

Bhuvaneshwaran Ilanthirayan's user avatar

asked Dec 12, 2023 at 19:00

0 votes

0 answers

87 views

create rdf graph using rdflib from yago 40k dataset

I have yago triple dataset splited into train ,test and valid which is format txt.when i tried to serialised it into rdf graph , I got error. so this is the code : from rdflib import Graph, URIRef ...

Halima Aoula's user avatar

asked Nov 25, 2023 at 17:01

0 votes

0 answers

62 views

On below example ttl I'm trying to run a query that would give me the relationshipLabel for specific combination of subject and object stated as canRelateTo. So for example: I want to query the value ...

Gero's user avatar

asked Nov 20, 2023 at 15:55

Sparql query returns undesired results when using blank nodes (rdflib)

I use rdflib python library to model a graph of contacts, and perform sparql queries to retrieve who knows who. This works fine when people as added as URIRef, but not when using BNode. The example ...

GabrielGodefroy's user avatar

asked Nov 3, 2023 at 7:47

1 vote

2 answers

200 views

Filter a TTL file too large for rdflib to parse in-memory otherwise

I am working on a large ttl file of 20 GB, I try to read in using rdflib but the I am getting a error killed To avoid this, I am trying to create a smaller file from this file using grep command. ...

Alexandra's user avatar

asked Oct 22, 2023 at 22:24

0 votes

0 answers

28 views

Problem with SPARQL query nested value extraction

I am trying to extract ?id ?label ?synonym ?dbXref ?isa ?someValuesFrom, from owl file with tags with the same below structure. <owl:Class rdf:about="http://purl.obolibrary.org/obo/...

Samaneh salehi nasab's user avatar

asked Oct 6, 2023 at 4:54

1 vote

0 answers

95 views

Insert via remote HTTP/SPARQL in Jena - Spring Boot 3

I am looking for a way to construct a SPARQL insert query in Jena, and upload it to a remote SPARQL endpoint (served by Virtuoso's Open Edition, if it matters). Most of the documentation references ...

LongStreak's user avatar

asked Oct 2, 2023 at 2:46

0 votes

1 answer

168 views

Incorrect result in SHACL validation

I am trying to validate a data graph against the shape graph using pyshacl. Basically, the data graph represents a geometric representation of two walls in a building, whose distance from each other ...

AJAY AGRAWAL's user avatar

asked Sep 30, 2023 at 0:05

1 vote

0 answers

59 views

BadSyntax error while validating Datagraph against SHACL shapes in pyshacl

I am trying to validate a data graph against a shape graph in pyshacl. The objective is to check the distance between two walls from a linked building data representation of a small building. The code ...

AJAY AGRAWAL's user avatar

asked Sep 27, 2023 at 0:13

0 votes

0 answers

31 views

Problems with codecs using graph.add() of RDFLib

I create a graph (RDFLib), in Python, with store "Oxigraph" indicating a path do store my graph, as we can see in the code below: 78 if os.path.exists(dirarqs + "\\g1_graph_dir")...

Jose Miguel Boeres Filho's user avatar

asked Sep 19, 2023 at 14:07

0 votes

0 answers

50 views

SPARQL query to match the entity type from two ttl files

I have a ttl file from Yago, and ttl file contains NER from DBpedia Examples Yago ttl files <Jungle_Lord> rdf:type <wordnet_oeuvre_103841417> . <Jungle_Lord> rdf:type <...

Rahul's user avatar

asked Sep 14, 2023 at 8:55

How to determine or filter datatype of a rdflib literal?

I haven't used rdflib in a while and am writing some trivial code based on https://rdflib.readthedocs.io/en/stable/intro\_to\_graphs.html#basic-triple-matching like from rdflib import Graph graph = ...

Mark Miller's user avatar

asked Aug 23, 2023 at 20:08

2 votes

2 answers

106 views

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: <https:/...

Mark Miller's user avatar

asked Aug 23, 2023 at 15:40

2 votes

1 answer

150 views

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 ...

CJ Acosta's user avatar

asked Jul 21, 2023 at 19:26

SPARQL Namespace conflict while querying

I'm quite puzzled by the behavior of my endpoint, nor by the processing of the request. The basic RDFS namespace seems to clash with another definition while querying, resulting in an error when ...

BathtubBear's user avatar

asked Jul 13, 2023 at 9:04

0 votes

0 answers

121 views

Selecting triples from an RDF graph where subject is in list1 or object is in list2 using Sparql in rdflib

Let G be an RDF graph and list1 and list2 be tow lists of URIs. I want to select all triples where ?subject ?p ?object such that ?subject is in list1 or ?object is in list2 using Sparql. I implemented ...

AmHsnSharafi's user avatar

asked Jul 9, 2023 at 13:10

Why is conversion from JSON-LD to Turtle in rdflib not working?

I am trying to make a simple script which converts JSON-LD to Turtle, and from Turtle to JSON-LD on demand. So far, I was using rdflib, and the Turtle -> JSON-LD part is working fine. I give some ...

Robin's user avatar

asked Jul 5, 2023 at 12:00

1 vote

0 answers

86 views

Why doesn't the 'HAVING' function work in RdfLib SPARQL queries?

I'm trying to use the HAVING funtion in a SPARQL query. While the query works fine in Protege, it does not return any result when I use it in a query in the rdflib package(it does not raise an error ...

Samah K's user avatar

asked Jun 4, 2023 at 11:44

How to set up the ID of a json element in rdflib

Context I am loading a rdf file in rdflib, and am trying to export it in json-ld. The original rdf looks like: <cim:Substation rdf:ID="_1234"> cim:IdentifiedObject.nameA ...

Guillaume's user avatar

asked May 11, 2023 at 7:27

Unable to validate and serialize new inferred graph from pyshacl

I'm stuck with a problem and I need your help. I'm working on pyshacl validation, which is a Python library for validating RDF graphs against SHACL graphs. I have a shacl shape graph that has a SPARQL ...

Kuladeep's user avatar

asked May 10, 2023 at 22:41

How to update RDF graph by instantiating the variables existing in triples with values?

I have a knowledge base that looks as follows: @prefix ex: http://example.org/ . @prefix rdfs: http://www.w3.org/2000/01/rdf-schema# . ex:a a ex:C . ex:C rdfs:subClassOf ex:D . ex:D ...

izolveidon's user avatar

asked May 10, 2023 at 22:03

0 votes

2 answers

412 views

how to read th RDF-Turtle Star file with Python?

I have a .ttls file . i want to read it with python and extract some information. I googled a bit. there is the library rdflib. but I think it doesn't support the .ttls file. does anyone have any idea ...

Pooriya Rezaei's user avatar

asked May 3, 2023 at 9:19

0 votes

2 answers

433 views

how create named graphs in GraphDB?

how create named graphs in GraphDB? Is it necessary to change the format de rdf file from triples to n-quads through tools (like RDFLib or Apache Jena) or is there an easier way?

Gisane Michelon's user avatar

asked Apr 10, 2023 at 18:12

0 votes

0 answers

122 views

Sparql query with both Union and Filter Criteria

How to use both union statement and regex pattern filter in a Sparql query when using Python, RDFLib. I need to obtain resources from a graph which are involved in either p1 or p2 property, and ...

Tara's user avatar

asked Apr 2, 2023 at 8:10

0 votes

0 answers

156 views

Regex Expression in Sparql - Mixed text and numbers

I have some resources that are identified by http://myexample.org/NNNN where NNNN is any number, for example, one resource may be http://myexample.org/9890\. I am using SPARQL and Python. To retrieve ...

User 19826's user avatar

asked Apr 2, 2023 at 4:46

How can I insert variable into SPARQL query?

I use the rdflib library. I need to insert a variable into a SPARQL query. I do this: q = prepareUpdate("""INSERT DATA { a owl:Ontology }""") g....

irina_ikonn's user avatar

asked Mar 20, 2023 at 11:09

0 votes

0 answers

119 views

How can I add an annotation for a property between two individuals using rdflib

I'm using rdflib in python to build a graph, and how can i use it to add an annotation for a property between two individuals. For example, graph namespace is <http//:example.com/test#>, two ...

charon's user avatar

asked Mar 10, 2023 at 8:56

3 votes

0 answers

59 views

Changing the join order in a custom RDFLib store

In a project we override the store triples method to generate virtual triples given a subject/predicate or predicate/object pair. And the logic depends on either the subject or object being bound to a ...

Jerven's user avatar

asked Mar 6, 2023 at 10:06

Parsing an ontology in Python using rdflib and Google Collab

I have an ontology in an 'owl' file (quran_data_full.owl) and I saved it in a folder in my google drive (Quran Corpus). I want now to perform some queries in this ontology and this is my first time ...

Reem's user avatar

asked Mar 1, 2023 at 10:38

1 vote

1 answer

377 views

Customize output of `serialize` from the rdflib Python library

Table of contents The context What I want to do Why I want to do this? The context I know how to generate a Turtle file using Python and rdflib. See minimal working example below. It generates a file ...

Rodrigo Morales's user avatar

asked Feb 22, 2023 at 3:31

1 vote

0 answers

616 views

Why does Python return 'ModuleNotFoundError: No module named ...' if the module is properly installed?

I'm trying to import "rdflib" (from rdflib import Graph) for my Python code. For some reason, when I launch the code, the console returns me ModuleNotFoundError: No module named 'rdflib'. I ...

Sebastiano G's user avatar

asked Feb 21, 2023 at 10:41