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.
393
questions
0
votes
0
answers
17
views
rdflib's parseQuery decode the query string which cause invalid URI
I have the following ttl file:
@prefix : <https://www.example.co/reserved/language#> .
<https://www.example.co/reserved/root> :_id "01G39WKRH76BGY5D3SKDHJP2SX" ;
:transcript%...
0
votes
1
answer
17
views
RDFLIB : SPARQL count query gives an inappropriate output
I am new to python and SPARQL. I am trying to get the count of the metadata where the subject is "social sciences" from a list of .ttl files. I am using the below code. However, the output ...
0
votes
1
answer
25
views
HTTPS connection with RDFLib
I am using Python and the RDFLib library and I want to perform an HTTPS connection to a SPARQL endpoint such as Amazon Nepute (HTTPS is mandatory) and perform authentication. However, I cannot find in ...
0
votes
0
answers
17
views
Know the ObjectProperty of two subclasses using owlready
I built an ontology for units as follows:
Class: Unit -> Class: Temperature -> Classes: K, deg C, etc
Class: UnitTerms -> Classes: heat dissipation, storage temperature,...etc
-> means ...
0
votes
0
answers
15
views
How to run SPARQL queries in R (WBG Topical Taxonomy) without parallelization
I am an R user and I am interested to use the World Bank Group (WBG) Topical Taxonomy through SPARQL queries.
This can be done directly on the API https://vocabulary.worldbank.org/PoolParty/sparql/...
2
votes
1
answer
28
views
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 ...
0
votes
0
answers
13
views
How can rdflib parse an arithmetic expression in RDF
To say an arithmetic expression like x=m/n^2, I express it in RDF as follows:
@prefix : <http://ex.org/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix math: <...
0
votes
2
answers
31
views
How to add an Ontology IRI with the Python rdflib library?
My problem is described here but the (maybe old) proposed solution does not work for me!
https://github.com/RDFLib/rdflib/issues/817
I would like to use rdflib to fill with Python the Ontology IRI ...
0
votes
1
answer
43
views
How to get all items of a blank node in rdflib
I'm new to RDflib, I want to implement a feature like this:
To say, Person hasProperty Weight(kg) , Height(m),
and BMI (Body Mass Index)=Weight/Height^2, so if Bob's Weight=70, Height=1.75, How to ...
0
votes
0
answers
30
views
How to compare two strings parsed as rdflib graphs and see which triples changed?
I am trying to compare two strings which hold triples. I have parsed the data as rdflib and I managed to compare the graphs by using the isomorphic method.
However, this method only compares the two ...
0
votes
0
answers
23
views
SparQL requesting a graph on the raspberry pi
I want to send sparql requests to an ontology (.owl file) in the context of object recognition using python on a raspberry pi.
rdflib turns out to be way too slow for that task. I wanted to use ...
0
votes
1
answer
56
views
Inserting Data from Dataframe into Ontology using SPARQL and RDFLIB in Python
I created an ontology using protegee and now want to insert data using RDFLIB in python. Because I have to write the update sparql statements in string and my data comes in various types including, ...
0
votes
0
answers
16
views
Why does pip install rdflib not work anymore?
pip stall rdflib doesn't work recently.
I tried pip (pip3) in jupiter notebook and pycharm lib manager pip (pip3, conda) all were no luck. The issue is that the installation process just not going ...
0
votes
0
answers
31
views
What SPARQL library does Wikidata Query Service "Format Query" feature use?
I am working on building SPARQL queries using Python and SPARQLBurger. My queries work fine, and now I want to format (or beautify) queries like Wikidata Query Service does when we click diamond ...
0
votes
0
answers
62
views
Using RDFLIB to fetch elements for every class
I have an OWL RDF data file that contains several data such as the following example:
<!-- http://purl.obolibrary.org/obo/OGMS_0000014 -->
<owl:Class rdf:about="http://purl....
0
votes
0
answers
38
views
PluginException: No plugin registered for (.nt, <class 'rdflib.serializer.Serializer'>)
I am able to serialize in .ttl format but when I tried serialize the rdf graph in (.nt,.ntriples,.nt11 format) by python. Everytime it is showing error:
PluginException: No plugin registered for (.nt, ...
0
votes
1
answer
124
views
How to represent predicates in RDF triples <s,p,o> by RDFlib
I am able to generate my RDF triples in .ttl format. I would like to ask two things:
When I save my RDF triples in .ttl format. It is saved taking subjects in alphabetical order automatically(triples ...
1
vote
0
answers
40
views
Get union entities from knowledge graphs
Some entities/classes present in knowledge-graphs have operations performed on them like 'Union', 'Intersection' etc. Below is one ontology file which has has lots of union operations on various of ...
0
votes
0
answers
38
views
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/...
0
votes
1
answer
37
views
Selecting literal values from Wikidata federated query service using RDFLib
I'm trying to get external identifiers for an entity in Wikidata. Using the following query, I can get the literal values (_value) and optionally formatted URLs (value) for Q2409 on the Wikidata Query ...
0
votes
0
answers
72
views
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 ...
0
votes
0
answers
33
views
rdflib.js Load data into the store from a buffer/string
I want to load an owl.file with rdflib.js based on this tutorial but get the following error:
Error: Error: NamedNode IRI "/ontologies/opcua.owl" must be absolute. while trying to parse </...
1
vote
1
answer
181
views
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. ...
0
votes
1
answer
35
views
RDFlib (python): freeing memory from the graph
I am declaring my graph as follows, which defines it in memory:
import rdflib as rdf
g = rdf.Graph() # create the RDF graph
then populate it with my triples and finally serialise it to a file as ...
0
votes
2
answers
34
views
assignment of bound prefix as variable
I'm missing something elementary here I'm sure. Parsing an rdf graph with rdflib gives you a graph object with a namespaces() method. This returns a list of tuples with prefixes that are bound to ...
0
votes
0
answers
94
views
How to search entity in an given knowledge graph with multiple ttl files locally?
I am now trying to query the knowledge graph in local. The knowledge graph is the CORD-19 Annotated By SemRep, which is a tar.gz file after downloading. I want to search if the entity or relation ...
0
votes
0
answers
65
views
Missing step importing URL to GraphDB
A newbie in semantic web, here. I have built a knowledge graph, my concepts already have URIs. However, my predicates do not have URIs and I created a vocabulary of my predicates - which is a ttl file ...
0
votes
1
answer
84
views
rdflib.plugins.sparql not found?
I am working through some basic rdflib stuff in python, trying to figure it out, and I am running into what seems like a basic problem.
The code is also here, the third example under Lecture 3: SPARQL....
0
votes
1
answer
70
views
python cgi interaction fails to find graphviz program twopi
I've got a maddening bug where my python script succeeds in doing something when run independently, but fails when run as a cgi script called by jquery's $.ajax(). Any insights would be welcome.
I'm ...
0
votes
1
answer
22
views
rdfLib turning a single backslash into multiple backslashes
I'm using rdfLib to serialize my triples in trig format (turtle based), but for some reason, the backslashes () in my sh:pattern statements (regex format) are doubled. I tried inputting the value for ...
0
votes
1
answer
157
views
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 ...
2
votes
1
answer
112
views
Retrieve objects from RDF triples
With the following snippet from the pizza ontology:
<owl:Class rdf:about="http://www.co-ode.org/ontologies/pizza/pizza.owl#Pizza">
<rdfs:subClassOf rdf:resource="http://www....
0
votes
2
answers
82
views
SPARQL query to return number of neighbor
I need to find just the amount of neighbor (up to 4 nodes away) of a given article in DBPedia (2 articles are neighbors when there's a wikilink between them). Currently I'm doing this query but it ...
3
votes
1
answer
147
views
Querying local SPARQL endpoint is very slow
I have setup a local SPARQL endpoint with DBPedia database using Openlink Virtuoso through this guide. Then I tried to query my database through Python with the help of RDFLib and SPARQLWrapper.
...
0
votes
0
answers
40
views
Finding out the Subgraph (Contex) identification using Object Value and Printing the graph
I am creating a rdflib graph and adding a tuple in it as show below.
The issue i am having is; i am not able to extract the graph name using only giving by the Object Value.
For example, i am using ...
0
votes
1
answer
130
views
Optimize SPARQL query for a very large database
Hello I am in need of optimizing my (rather simple) query over a very large database (in particular DBPedia). I'm currently using rdflib and SPARQLWrapper for Python.
Currently I need to do a ...
0
votes
0
answers
13
views
Remove all localizations except en when using rdflib.serialize
I am using rdflib.Serialize to dump a RDF graph in Turtle format.
Here is my code:
g2.serialize(destination="file.ttl", format="ttl")
Here is my output:
dcat:theme rdfs:comment &...
0
votes
1
answer
150
views
RDFlib parsing large turtle files memory error
I'm trying to parse large .ttl file 1,4 Gb with a help of rdflib in Python and getting memory error.
I've already tried to open triple store in rdflib g.open("store", create=True), but then ...
0
votes
0
answers
38
views
How to store XSD.float with INF in rdflib
Can anyone tell me how to store a XSD.float with the value Infinite as a Literal in rdflib?
XSD.float allows an infinite value and requires it to be stored as INF (see here).
But both intuitive ...
1
vote
1
answer
133
views
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 ...
4
votes
2
answers
191
views
python 3.9 and rdflib keep changing slashes in a url
I am completely new in Python . I am using 3.9.2 and rdflib . I try to execute the first example,
from rdflib import Graph
g = Graph()
g.parse('http://dbpedia.org/resource/Semantic_Web')
for s, p, o ...
0
votes
1
answer
177
views
Accessing file in turtle (.ttl) file via Python rdflib
I'm trying to parse the data in .ttl format following suggestions I found here. My approach:
from rdflib import Graph
file = 'XYZ.ttl'
graph = Graph()
graph.parse(file, format='...
0
votes
1
answer
98
views
Adding triples in a certain order using RDFLib Python
I am looking to add triples in a certain order using Python's RDFLib Library. I'm aware RDF triples have no ordering, however, I was hoping to add the triples in the order in which the add() function ...
1
vote
1
answer
74
views
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 ...
0
votes
0
answers
30
views
rdflib R package - cannot capture error message
I am using the rdflib R package to read rdf files. The issue I am facing is that sometimes there are errors thrown when I call rdf_parse() on a file, but the function still returns the triplets it ...
0
votes
1
answer
154
views
Parsing HTML+RDFa in RDFLib
RDFLib seems to support parsing RDFa data. Upon implementing a snippet to parse an RDFa-annotated HTML page, I run into this problem:
Traceback (most recent call last):
File "/home/zonk/.local/...
0
votes
1
answer
246
views
How to make multiple RDF graphs from a list of dictionaries (triples) with RDFlib in Python?
What I have: A list of 20k dictionaries (triples) that need to be transformed to RDF using RDFlib.
Goal: For every triple, I want a new rdf Graph(). However, when I loop through all the triples, the ...
0
votes
1
answer
108
views
How to add a compound node using RDFLib?
I'm new to using Python's RDFLib (so apologies for incorrect use of terms and such!), and am looking for a way to add the following to a node:
prov:qualifiedAssociation [ a prov:Association ; prov:...
1
vote
1
answer
213
views
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,
<http://example.org/show/...
0
votes
1
answer
82
views
How to run a SPARQL update statement using RDFLIB in python
I know there is an update statement in SPARQL, but I am not really sure how to use it in RDFLIB. For instance, I have an ontology that contains Alice and Julius as individuals and I want to run a ...