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

Fetching triples using SPARQL query from turtle file

I am new to SPARQL and currently struglling to fetch triples from a turtle file. ### https://ontology/1001 rdf:type owl:Class ; rdfs:subClassOf ; …
rshar
  • 1,381
  • 10
  • 28
2
votes
1 answer

python rdflib doesn't export @context and @graph when serializing with json-ld

I have created a Graph() in rdflib 6.2.0 and attempting to export it as JSON-LD. My expectation was that I would end up with a @context containing all the namespace prefixes and a @graph containing all the elements. I'm just simply…
O-U-O
  • 69
  • 5
2
votes
2 answers

Adding blank nodes in triples

The code written below gives the following output: Code: person =…
2
votes
2 answers

Creating Owlready2 properties dynamically

I am in need of creating an ontology dynamically. for classes I am creating them using below method. with onto: NewClass = types.new_class(class_name, tuple(SuperClasses)) But for creating properties(object/data etc..) I am unable to find a way…
Zenmate
  • 41
  • 4
2
votes
0 answers

How to pass in a list of values for SPARQL query using rdflib?

With rdflib's Graph.query, is there a way to pass in a list of values to use in a SPARQL query? I'm aware of the initBindings argument for binding single values to variables, but I'm looking to pass in the equivalent of a VALUES block. Conceptually,…
King Chung Huang
  • 5,026
  • 28
  • 24
2
votes
1 answer

How to create a knowledge graph from a pandas dataframe using RDFLIB library in Python

I have a df from which I need to create a Knowledge Graph using RDFlib library in Python. So that I can visualize the created knowledge graph in various visualization tools like Protege, Webowl etc. How can this be done?
Arya Stark
  • 205
  • 1
  • 11
2
votes
1 answer

Retrieve objects from RDF triples

With the following snippet from the pizza ontology:
gedman
  • 63
  • 5
2
votes
1 answer

How can I get the list of movies by a director from dbpedia using sparql query

I have been facing a great deal of difficulty trying to write a python code that will return the list of movies by the director called Francis Ford Coppola. Below is a good that I have so far your assistance will be greatly appreciated. I have also…
Fornow
  • 69
  • 1
  • 9
2
votes
1 answer

How to get XML Attributes via rdflib

I have an rdf file with the following content:
Lukas Schmid
  • 1,895
  • 1
  • 6
  • 18
2
votes
0 answers

Transitive inference with OWL-RL on RDFLIB

I am trying to use an OWL reasoner on an RDF graph which I have created using rdflib as follows: ex = Namespace('http://example.org#') g = Graph() g.bind("ex", ex) g.add((ex.Bob, ex.drives, ex.Car)) g.add((ex.Car, RDF.type,…
Joel Oduro-Afriyie
  • 1,563
  • 14
  • 13
2
votes
0 answers

owlready2 rdfs:subClassOf inference doesn't work

I created an rdflib graph and serialised it into an owl file formatted as XML. I explicitly write A RDF.type RDFS.Class and B RDFS.subClassOf A. After I do this. onto =…
lamename
  • 31
  • 2
2
votes
1 answer

How to use SPARQL command INSERT with rdflib? (not INSERT DATA)

Using python's rdflib, I am trying to insert new triples into a graph based on some basic manipulations with existing triples. For instance, in this basic example, I create a graph that I populate using INSERT DATA with 4 triples. I then try to…
2
votes
2 answers

Find all triples in a given RDFLib namespace

I would like to retrieve property/object pairs of a given subject, but only for these properties matching a specific namespace (let us say rdflib.RDFS.) Something like g.predicate_objects(s, prop_prefix=RDFS). Is there a built-in way to achieve…
Florent Georges
  • 2,190
  • 1
  • 15
  • 24
2
votes
1 answer

How to use rdflib to query WikiData?

I mean that I want to use rdflib to query WIkidata in my local computer, but rdflib.Graph() need to parse the namespace firstly.THerefore, How can I get the Wikidata NameSpace to use the rdflib local code?
zqhead
  • 21
  • 2
2
votes
1 answer

Does RDFlib available for micropython?

If RDFlib is not available for Micropython, is there any other library available for Micropython to work with RDF?
Madhubhani
  • 25
  • 4