sparql

SPARQL - Unknown namespace prefix error

痞子三分冷 提交于 2019-12-11 14:24:09
问题 I have a python file with imported rdflib and some SPARQL query implemented from rdflib import Graph import html5lib if __name__ == '__main__': g = Graph() g.parse('http://localhost:8085/weather-2.html', format='rdfa') res1 = g.parse('http://localhost:8085/weather-2.html', format='rdfa') print(res1.serialize(format='pretty-xml').decode("utf-8")) print() res2 = g.query("""SELECT ?obj WHERE { <http://localhost:8085/weather-2.html> weather:region ?obj . } """) for row in res2: print(row) res1

SPARQL Geospatial Queries (MarkLogic)

不羁的心 提交于 2019-12-11 14:17:43
问题 Carrying on from a previous question here. Where it was noted that avoiding fn:doc() should be avoided in SPARQL queries. However, for geospatial queries aside from the code shown below I am unable to find an alternative solution. I have also used this query and it's runtime is really slow. For bigger set of data it will hit the 1 hour timeout. Hence, I would like to ask if there is a better way in implementing Geospatial queries for SPARQL? Is it possible to use GEOSPARQL with PREFIX spatial

Connecting Linkedmdb and DBpedia via federated SPARQL queries

眉间皱痕 提交于 2019-12-11 13:49:39
问题 I ran the following query and got the data for movies and their corresponding DBpedia URI from linkedmdb. SELECT ?film ?label ?dbpediaLink WHERE { ?film rdf:type movie:film . ?film rdfs:label ?label . ?film owl:sameAs ?dbpediaLink FILTER(regex(str(?dbpediaLink), "dbpedia", "i")) } LIMIT 100 I want to get the category for these movies from DBpedia using the ?dbpediaLink URI. Also, I need to get the value of the dcterms:subject property for the movie from DBpedia. I am not able to understand

Jena TDB after reason then update

让人想犯罪 __ 提交于 2019-12-11 13:44:18
问题 I am using Jena and I want to update the new ontology into my tdb. For example. I have 100 rows in my ontology , after I add some rules and run the reasoner, there are 105 rows now. And I need to update these 5 additional rows in my tdb. How can I get this done ? I try to google it and I found two ways. One is using sparql to update , another is truncating the tdb and add the new model into it. Is there any other better solution? Thanks you -- code void after_reasoner(Model m) { String yago =

Sesame repository not being updated using INSERT despite no error

你说的曾经没有我的故事 提交于 2019-12-11 13:43:34
问题 I am trying to update a Sesame repository with data from dbpedia. I have the following query: PREFIX owl: <http://www.w3.org/2002/07/owl#> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX dc: <http://purl.org/dc/elements/1.1/> PREFIX : <http://dbpedia.org/resource/> PREFIX dbpedia2: <http://dbpedia.org/property/> PREFIX dbpedia: <http:/

Selecting multiple results from query

夙愿已清 提交于 2019-12-11 13:13:20
问题 I have this query for example which returns four results. What I am doing with this code is selecting one of those results through an integer, so that I can do another query for it later. What I have been trying to do, and haven't been able to yet, is select more than just one result, so that I can reuse them separately. For example this query would return: RESULT A RESULT B RESULT C RESULT D I can type, for example, 1 in the console and get that value in a string and reuse it. What is a

Select (combine) multiple attribute values - SPARQL / RDF

大兔子大兔子 提交于 2019-12-11 13:01:45
问题 I have RDF like the following: resource: r1 <dc:title>Mathematics</dc:title><dc:title>Chemistry</dc:title><dc:size>39</dc:size> resource:r2 <dc:title>Biology</dc:title><dc:size>42</dc:size> And I have this SPARQL query to extract the values: PREFIX dc: <http://purl.org/dc/elements/1.1/> select distinct ?resource ?title ?size where { ?resource dc:title ?title ?resource dc:size ?size } Results: resource title size r1 Mathematics 39 r1 Chemistry 39 r2 Biology 42 But I want to have the following

Finding common categories or supercategories of resources

早过忘川 提交于 2019-12-11 12:57:30
问题 I'm wondering if we can know whether two resources have the same category or some subcategory (i.e., belong to categories of some common supercategory) in DBpedia? I tried this query in the DBpedia endpoint but it's wrong: select distinct ?s ?s2 where { ?s skos:subject <http :// dbpedia.org/resource/ Category ?c. ?s2 skos:subject <http :// dbpedia.org/resource/ Category ?c2. ?c=?c2. } 回答1: DBpedia doesn't use skos:subject for resources, but rather relates resources to their Wikipedia

can I do this in AllegroGraph prolog?

戏子无情 提交于 2019-12-11 12:51:54
问题 I have an RDF file and I need to extract some information from it in a single line. Now, I'm using AllegroGraph with Prolog query engin : (select (?result) (q ?a !rdfs:label ?alabel) (q ?b !rdfs:label ?blabel) (lisp ?result (string+ ?alabel " AND " ?blabel))) to get the results in a single line: "{a1} AND {b1}" "{a1} AND {b2}" "{a2} AND {b1}" "{a2} AND {b2}" Now, I need to group all the rows of ?result in a single line with the string "OR". so i get: "{a1} AND {b1} OR {a1} AND {b2} OR {a2}

Ontology and the Web

≡放荡痞女 提交于 2019-12-11 12:46:47
问题 I've been having trouble accessing an ontology that we built here via the web. I've been trying to understand sparql and as far as I can tell there's no real PHP support for ontologies yet. I was wondering if I'm going about this right trying to build a java server app that queries the ontology for me that I just access? Or is there an easier better way? Can anyone help with their own knowledge or good references to read? I've been searching and reading for awhile now and can't find much of