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
1
vote
0 answers

raise BadSyntax(self._thisDoc, self.lines, argstr, i, msg) rdflib.plugins.parsers.notation3.BadSyntax:

I tried to parse a file in turtle format but I am getting this error and cannot find how to solve it : Traceback (most recent call last): File "/gpfs7kw/linkhome/rech/genlig01//test/expe_5/dbnary_corpus/extract.py", line 25, in
kely789456123
  • 605
  • 1
  • 6
  • 21
1
vote
1 answer

How do I convert a rdflib.term.URIRef back into a string that includes a namespace prefix?

I am working with rdflib. I am parsing Turtle files that include namespace prefixes. When I get my triples back from the SPARQL query, they contain rdflib.term.URIRef elements, which print as things like…
vy32
  • 28,461
  • 37
  • 122
  • 246
1
vote
1 answer

Using variables with stored values in RDFLIB and Python for Sparql update statement

I am quite new to RDFLIB and I am trying to learn how to use Delete/Insert statement to continually update data property values of individuals in my ontology from a CSV file. I am using pandas dataframe to do this but I am now stuck. I am able to do…
1
vote
1 answer

How to get token position in sparql query in rdflib

How to obtain a given token type (uri, literal, ...) and location from a given sparql query using rdflib? For instance, given the following query: SELECT count(DISTINCT ?uri) as ?count FROM graph WHERE { ?uri a ?type; graph:predicate_a…
Daniel
  • 127
  • 1
  • 9
1
vote
1 answer

Use of IRI in RDF N-Triples

I am trying to convert a csv file into RDF N-triples using RDFLib in python. It seems that subject must be an IRI/blank node and also Predicate must be an IRI. For example,
1
vote
1 answer

Set Operators, "in" operator, BNodes?

I am trying to understand the logic of Set Operations (Union, Addition, Intersection, Difference,Xor) in RDFlib, and have done some tests with identical files for which the results didn't match my naive expectations. Therefore, I have tested the…
Joel Thill
  • 25
  • 4
1
vote
1 answer

Is there a way to back translate a SPARQL query parse-tree to a query string using python's rdflib module?

With python's rdflib I can parse a SPARQL query string and translate its algebraic form with following syntax: statement = "Select ?s ?p ?o where {?s ?p ?o.}" query_tree = parser.parseQuery(statement) # query parse-tree q_algebra =…
Greenfish
  • 358
  • 2
  • 5
  • 19
1
vote
1 answer

SPARQL: FILTER out subjects which appear as objects in any other SELECTed triple

I need to retrieve triples for entities which have a transitive relationship, but I only want as subjects the entity at the end of the transitivity chain. For the following example: @prefix rdfs: . <:a0>…
Leobeeson
  • 500
  • 6
  • 13
1
vote
1 answer

Use Virtuoso store with RDFLIB

I am trying to use https://pythonhosted.org/virtuoso/ with RDFlib but I keep getting the following import error ~\miniconda3\envs\dlvr\lib\site-packages\virtuoso\__init__.py in 2 from pkg_resources import DistributionNotFound 3…
Aniqa295
  • 21
  • 1
1
vote
2 answers

Expressing Sentences in Google RDF Format

I would like to write a python code to express a graph like this: Jim → is eating → an apple An apple → is in → the kitchen in RDF format. I have tried the RDFlib in python but I am confused about how to do it. I would appreciate if anybody could…
1
vote
0 answers

rdflib query sparql cause error with group by

I am trying to run a sparql query on a local rdf dataset. The dataset is parsed successfully. The following query containing the group by clause gives the exception 'Cannot eval thing: None ()' select (COUNT(?person) as ?cnt) …
Aniqa295
  • 21
  • 1
1
vote
0 answers

I am trying to query my Ontology which I created on Protege by SPARQL (I am 2 weeks old Python user) and I didnt take any error or result either

This is What I wrote after importing rdflib and my owl data. I wrote 3 query part, and I couldnt take any answer from all. * PREFIX : "" g = Graph() g.bind("foaf", FOAF) First one: qres = g.query( …
GamzeGG
  • 11
  • 3
1
vote
1 answer

Workflow for interpreting linked data in .ttl files with Python RDFLib

I am using turtle files containing biographical information for historical research. Those files are provided by a major library and most of the information in the files is not explicit. While people's professions, for instance, are sometimes stated…
OnceUponATime
  • 450
  • 4
  • 12
1
vote
0 answers

How to Join two Query in SPARQL python (sparql-client)

I am writing a SPARQL query to get name and expertise from 2 rdf files. Using rdflib graph() I can parse and query one rdf files at a time but I could not get the join ideas here. How can I do that? How can I parse two rdf files and make a join…
Meshu Deb Nath
  • 73
  • 1
  • 10
1
vote
3 answers

rdflib not parsing RDF/XML file

I am trying to load and parse a very simple rdf file in xml format using rdflib. I don't think, it is parsing correctly. Here is my rdf/xml file,
Laeeq Khan
  • 167
  • 10