Using Python rdflib: how to include literals in sparql queries?

I can include URIs and variables in my queries, but I can't include literals in my queries. Here, I have some code which successfully reads an RDF file, finds all the RDF triples with...

How to export graph in RDF file using RDFLib

I'm trying to generate RDF data using RDFLib in Python 3.4. A minimal example: from rdflib import Namespace, URIRef, Graph from rdflib.namespace import RDF, FOAF data =...

rdflib "repeat node-elements" parse error with OWL/XML file

I have an OWL file prepared in Protege by someone else. I'm trying to parse it with the following Python code, but keep getting a parse error. import rdflib g=rdflib.Graph() result =...

RDFLib parser does not recognize json-ld format

My code in Python 3.4: from rdflib import Graph, plugin import json, rdflib_jsonld from rdflib.plugin import register, Serializer register('json-ld', Serializer, 'rdflib_jsonld.serializer',...

Visualize an RDFLIB Graph in Python

I am new to RDFLIB in python. I found this example of creating a graph on here. What is the simplest way to visualize graph created by this code? import rdflib # Now we create a graph, a...

How to process a .ttl file of 3 attributes using rdflib (python 3.x)?

I have a .ttl file which consists of 3 attributes. Ex: <http://dbpedia.org/resource/James_B._McLeran> <http://www.w3.org/2000/01/rdf-schema#label> "James B. McLeran"@en . How can I parse and store...

Querying letter mu in Sparql

I am using python library RDFLIB to query on semantic dicom owl file. I need to query for a label containing letter mu. I am not able to figure out how to query for labels containing this letter....

RDFLib: How to create ontology in Python?

I am defining an ontology for Urban system using rdflib in Python. I defined the class urbanSystem and the subClass name. import rdflib from rdflib.graph import Graph, ConjunctiveGraph from rdflib...

RDFlib count not working in SPARQL query

I am exploring python based library 'RDFlib' with native store (Sleepycat). A basic "select * ..." query works fine but COUNT does not seem to work. Here is my code: from rdflib import...

How to get graph's namespaces in rdflib

I've loaded an RDF file in Python, using rdflib: g = rdflib.Graph() g.parse ( "foaf_ex.rdf" ) the *.rdf defines a number of prefix/namespace pairs (e.g., foaf:) and I know they come into g...

visualize n-triple file python

Is there a module or tool in Python that will help me visualize RDF data? I have a N-Triple file and want to load it in python and display the information in it visually. I am currently using...

Using prefixes to display entities from an rdflib graph

I'm using rdflib to load an RDF graph into a Python scrpit I would like to print a list of subjects using the defined prefixes I doesn't find any method to apply the prefixes. My code import...

KeyError: 'collectstatic' When deploying the Django application to pythonanywhere

During the implementation of my Django application on pythonanywhere for the first time I encountered such an error. Previous applications with a very similar structure were able to be implemented...

Segmentation fault with tensorboard 1.14

I am using deeplab network. I think it is using tensorflow 1.14 since there are still packages of slim, which is removed from tensorflow 2.0. The python version is always Python 3.6.8 in my...

How to create a class with properties using RDFlib

I am trying to develop an ontology using Python RDFLib. I am new to python and RDFlib, Can anyone provide a simple example of how I can create a class, adding properties to that class, create...

TypeError: expected string or bytes-like object in owlready library

I'm trying to query data with python in the owl file I created using the owlready library. But I get the following error. what would be the reason? The code structure and received error are as...

Is there a way to iteratively add a list to a graph in rdflib?

I have lists of literals that I would like to add as rdf:lists to a graph. I can read rdf:lists without issue using rdflib.collection.Collection, but I haven't been able to add those lists to...

ModuleNotFoundError: No module named 'dicom' in a python env (tensorflow issue ?)

That's my first question here, but that won't be the first time Stack Overflow save me ! I am using conda on a windows10 machine and created my env with tensorflow 2.0 When I tried to add pydicom...

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

conda update InvalidSpecError

I am trying to update a conda environment: conda update --all but get the following Fetching package metadata ............. InvalidSpecError: Invalid spec: =20190808 output of conda list is as...

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

Ontologies and Graph-tool Python

Is there a way to create a graph from an ontology file using Graph-tool library in Python? I've done some research and what I've found is: Graph Tool doesn't support .owl and .rdf files. There is...

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

#rdflib (python): how to get a URIRef from a string such as 'ns:xxx'?

I have a RDFlib graph g, whose NameSpaceManager is aware of some namespaces. How do I get a URIRef from a string such as 'ns:xxx', where ns is the prefix associated to a namespace known by...

Load RDF file to OrientDB using Apache tinkerpop gremlin

I'm using OrientDB with gremlin server (https://s3.us-east-2.amazonaws.com/orientdb3/releases/3.1.1/orientdb-tp3-3.1.1.zip) and my requirement is to load a RDF file to orientDB. I'm using rdflib...

Cannot delete any triple from GraphDB using pythons SPARQLWrapper

I am trying to delete a simple triple from GraphDB (version = GraphDB free) using python's SPARQLWrapper and the code snippet I found here: https://github.com/RDFLib/sparqlwrapper - Update...

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

Updating packages in conda

I have a problem with updating packages in conda. The list of my installed packages is: # # Name Version Build Channel _anaconda_depends 2020.07 ...

Preserving comments in Turtle RDF file (RDFlib)

I would like to preserve the comments, these comments are defined using the hash sign (#) within the Turtle RDF file I am updating with the Python RDFLib library. My RDF file looks like this #...

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