rdflib

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

时间秒杀一切 提交于 2019-12-03 09:06:17
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 skos:prefLabels, counts them, and then identifies a couple of specific ones from a set of keywords: import rdflib.plugins.sparql as sparql import rdflib import rdflib.graph as g graph = g.Graph() # Read the RDF file graph.parse( 'h:\......SKOSTaxonomy.rdf', format='xml') # Build and execute the query q = sparql.prepareQuery('SELECT ?s ?p ?o WHERE { ?s ?p ?o .}') p = rdflib.URIRef("http://www.w3.org/2004/02/skos

how to parse big datasets using RDFLib?

こ雲淡風輕ζ 提交于 2019-12-03 07:41:58
问题 I'm trying to parse several big graphs with RDFLib 3.0, apparently it handles first one and dies on the second (MemoryError)... looks like MySQL is not supported as store anymore, can you please suggest a way to somehow parse those? Traceback (most recent call last): File "names.py", line 152, in <module> main() File "names.py", line 91, in main locals()[graphname].parse(filename, format="nt") File "/usr/local/lib/python2.6/dist-packages/rdflib-3.0.0-py2.6.egg/rdflib/graph.py", line 938, in

how to parse big datasets using RDFLib?

冷暖自知 提交于 2019-12-02 21:12:06
I'm trying to parse several big graphs with RDFLib 3.0, apparently it handles first one and dies on the second (MemoryError)... looks like MySQL is not supported as store anymore, can you please suggest a way to somehow parse those? Traceback (most recent call last): File "names.py", line 152, in <module> main() File "names.py", line 91, in main locals()[graphname].parse(filename, format="nt") File "/usr/local/lib/python2.6/dist-packages/rdflib-3.0.0-py2.6.egg/rdflib/graph.py", line 938, in parse location=location, file=file, data=data, **args) File "/usr/local/lib/python2.6/dist-packages

converting RDF to OWL

怎甘沉沦 提交于 2019-12-01 12:20:12
问题 I want to generate RDF code that follows the OWL format. I am able to generate an RDF file, but I need to convert it into OWL. Below is the RDF that I can generate. <?xml version="1.0" encoding="UTF-8"?> <rdf:RDF xmlns:ns1="http://example.com/nodetypes/2012/04/24/vehicle/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" > <rdf:Description rdf:about="http://example.com/nodetypes/2012/04/24/vehicle/2"> <ns1:nodetype_ptr_id>2</ns1:nodetype_ptr_id> <ns1:slug>vehicle</ns1:slug> <ns1:last

SPARQL query on the remote remote endpoint RDFLib / Redland

孤街浪徒 提交于 2019-11-30 19:22:10
I'm trying to query remote endpoints and get get owl:sameAs mappings, I've tried both RDFLib and Redland but neither worked for me, probably I'm not dealing with namespaces correctly. Here is my attempt in RDFLib: import rdflib rdflib.plugin.register('sparql', rdflib.query.Processor, 'rdfextras.sparql.processor', 'Processor') rdflib.plugin.register('sparql', rdflib.query.Result, 'rdfextras.sparql.query', 'SPARQLQueryResult') g = rdflib.Graph() query = """ SELECT * FROM <http://api.talis.com/stores/bbc-backstage/services/sparql> WHERE { ?s a http://purl.org/ontology/mo/MusicArtist; http://www

Determining Hypernym or Hyponym using wordnet nltk

笑着哭i 提交于 2019-11-30 07:31:34
I want to check for the hypernyms/hyponym relation between two words (given by the user) which means any of them can be hypernym of other or it can also be the case that there is no hypernym relation between the two.Can I use path_similarity for the same.I am trying to do like this.If you can suggest any better method for that.I also want to know if it is better to check the same from a sparql query first=wn.synset('automobile.n.01') second=wn.synset('car.n.01') first.path_similarity(second) alvas Firstly, there is a difference between word and synset / concept in wordnet. Here we see that one

SPARQL query on the remote remote endpoint RDFLib / Redland

泪湿孤枕 提交于 2019-11-30 03:51:58
问题 I'm trying to query remote endpoints and get get owl:sameAs mappings, I've tried both RDFLib and Redland but neither worked for me, probably I'm not dealing with namespaces correctly. Here is my attempt in RDFLib: import rdflib rdflib.plugin.register('sparql', rdflib.query.Processor, 'rdfextras.sparql.processor', 'Processor') rdflib.plugin.register('sparql', rdflib.query.Result, 'rdfextras.sparql.query', 'SPARQLQueryResult') g = rdflib.Graph() query = """ SELECT * FROM <http://api.talis.com

RDFLib: Namespace prefixes in XML serialization

混江龙づ霸主 提交于 2019-11-29 11:20:29
In a Python script using RDFLib 3.0 , I get the following XML-Output when serializing my triples: <rdf:RDF xmlns:_3="http://www.my-example.intra/ontologies/ci.owl#" > How can I define specific namespace prefixes for those anonymous _x-prefixes automatically assigned by RDFLib (or it's XML-Serializer respectively)? <rdf:RDF xmlns:ex="http://www.my-example.intra/ontologies/ci.owl#" > Many thanks in advance for your responses! I eventually found a solution to this by looking at some (quite messily distributed) rdflib doc files. For the (Conjunctive)Graph storing the triples, call mygraph.bind

Determining Hypernym or Hyponym using wordnet nltk

拥有回忆 提交于 2019-11-29 09:43:06
问题 I want to check for the hypernyms/hyponym relation between two words (given by the user) which means any of them can be hypernym of other or it can also be the case that there is no hypernym relation between the two.Can I use path_similarity for the same.I am trying to do like this.If you can suggest any better method for that.I also want to know if it is better to check the same from a sparql query first=wn.synset('automobile.n.01') second=wn.synset('car.n.01') first.path_similarity(second)

RDFLib: Namespace prefixes in XML serialization

我只是一个虾纸丫 提交于 2019-11-28 04:55:20
问题 In a Python script using RDFLib 3.0, I get the following XML-Output when serializing my triples: <rdf:RDF xmlns:_3="http://www.my-example.intra/ontologies/ci.owl#" > How can I define specific namespace prefixes for those anonymous _x-prefixes automatically assigned by RDFLib (or it's XML-Serializer respectively)? <rdf:RDF xmlns:ex="http://www.my-example.intra/ontologies/ci.owl#" > Many thanks in advance for your responses! 回答1: I eventually found a solution to this by looking at some (quite