sparql

Filter by language only if the object is a literal

丶灬走出姿态 提交于 2019-12-06 01:51:38
问题 I've written the following query: SELECT DISTINCT ?predicate ?object ?label WHERE { VALUES ?subject { <http://dbpedia.org/resource/Hercules_(1997_film)> } ?subject ?predicate ?object . ?predicate rdfs:label ?label . FILTER(langMatches(lang(?object), "EN")) } LIMIT 100 When I write the FILTER line this way, I've essentially filtered out all non-literals ( side question: are literals the only type that can have a language tag? ) So, how do I keep all of my results and filter out non-english

How to get Wikidata labels by ID using SPARQL?

☆樱花仙子☆ 提交于 2019-12-06 01:27:13
问题 How can I get the labels in English or any other language in Wikidata by ID using SPARQL endpoint? 回答1: Suppose wd:Q146190 is your wikidata entity ID get the label in a specific language of your specific entity ID: PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX wd: <http://www.wikidata.org/entity/> SELECT * WHERE { wd:Q146190 rdfs:label ?label . FILTER (langMatches( lang(?label), "EN" ) ) } LIMIT 1 live example in english live example in german get all the labels in any language

Query dbpedia sparql endpoint using dotnetRDF - RDFParseException

ぃ、小莉子 提交于 2019-12-06 01:06:16
When I execute the following query on http://dbpedia.org/sparql using (dotnetRDF) VDS.RDF.Query.SparqlRemoteEndpoint.QueryWithResultSet() everything works fine. SELECT ?film ?p ?o WHERE { ?film <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:Japanese_films> . ?film ?p ?o } limit 500 But when I try this query using SparqlRemoteEndpoint.QueryWithResultGraph() CONSTRUCT { ?film ?p ?o} WHERE { ?film <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:Japanese_films> . ?film ?p ?o } limit 500 I've got RdfParseException with message "[Line 456 Column 29]

Find the two nearest neighbors of points

流过昼夜 提交于 2019-12-06 01:05:19
I want to find the two nearest neighbors of each point dataset : :p1 :has_position 1 . :p2 :has_position 2 . :p3 :has_position 3 . :p4 :has_position 4 . expected results : ?POINT ?NEIGHBORS "p1" "p2; p3" "p2" "p1; p3" "p3" "p2; p4" "p4" "p2; p3" I try something like this : SELECT ?POINT ?POS (group_concat(?idPointN;separator='; ' )as ?NEIGHBORS) WHERE{ ?idPoint :has_position ?POS . ?idPointN :has_position ?POSN . FILTER (?idPoint != ?idPointN) } GROUP BY ?POINT ?POS this return all the neighbors of points. I want to do somthing like ORDER BY(?POS-?POSN) and limit 2 in the group_concat but i

Optimization of SPARQL query. [ Estimated execution time exceeds the limit of 1500 (sec) ]

两盒软妹~` 提交于 2019-12-05 22:49:34
I am trying to run this query on http://dbpedia.org/sparql but I get an error that my query is too expensive. When I run the query trough http://dbpedia.org/snorql/ I get: The estimated execution time 25012730 (sec) exceeds the limit of 1500 (sec) ... When running the query through my python script using SPARQLWrapper I simply get an HTTP 500. I figure I need to do something to optimize my SPARQL query. I need the data for iterating over educational institutions and importing it in to a local database, maybe I am using SPARQL wrong and should do this in a fundamentally different way. Hope

No result found on delete

别说谁变了你拦得住时间么 提交于 2019-12-05 21:59:06
I have the following delete statement: delete {?s ?p ?o} {<http://www.example.org/test/unit213> ?p ?o. ?s ?p ?o} The URI http://www.example.org/test/unit213 is valid, since I get on select, among others, <http://www.example.org/test/unit213> rdf:type <http://www.example.org/test/unit> Still, I get the following result: No result Can anyone tell me why? That's probably correct, SPARQL Update operations aren't supposed to return any results. By the way, I would discourage that style of Update without the WHERE keyword, it's very easy to misread. - Steve 来源: https://stackoverflow.com/questions

SPARQL query to construct sub-graph with select paths (paths have different lengths)

ぐ巨炮叔叔 提交于 2019-12-05 21:37:02
Is it possible to CONSTRUCT an RDF sub-graph that contains nodes A, B, C, E, F (but no D, G, H) from the following graph (in notation subject-predicate-object for a total of 7 statements) using a single SPARQL query: A-p-B A-q-C A-r-D A-s-E E-t-F A-u-G G-v-H I know how to formulate a SPARQL query that returns { A-p-B, A-q-C } (i.e. two paths consisting of 1 statement each) and one that returns { A-s-E E-t-F } (i.e. one path consisting of 2 statements). But it it possible to fold both into as single SPARQL CONSTRUCT query and if so, how would that look? It's much easier to work with data if you

How to return SPARQL results in JSON-LD?

ぐ巨炮叔叔 提交于 2019-12-05 21:26:31
What is a good way to return SPARQL query results in JSON-LD , preferably staying close to the standardized JSON format ? Can JSON-LD be returned for every query or only for certain query types? An example of a SPARQL query result in JSON format (i.e., without JSON-LD enrichment): { "head": {"vars": ["s", "p", "o" ]}, "results": { "bindings": [ { "s": { "type":"uri", "value":"http://www.w3.org/1999/02/22-rdf-syntax-ns#type" }, "p": { "type":"uri", "value":"http://www.w3.org/1999/02/22-rdf-syntax-ns#type" }, "o": { "type":"uri", "value":"http://www.w3.org/1999/02/22-rdf-syntax-ns#Property" } }

DISTINCT only on one value with SPARQL

点点圈 提交于 2019-12-05 20:35:51
问题 I want to retrieve with SPARQL the list of the italian cities with more than 100k of population and I'm using the following query: PREFIX dbo: <http://dbpedia.org/ontology/> SELECT ?city ?name ?pop WHERE { ?city a dbo:Settlement . ?city foaf:name ?name . ?city dbo:populationTotal ?pop . ?city dbo:country ?country . ?city dbo:country dbpedia:Italy . FILTER (?pop > 100000) } In the results I get for example in two different lines (which represent the same entity, but with different names): http

How to make a class label shown as the column name of the class?

笑着哭i 提交于 2019-12-05 20:00:36
The SPARQL SELECT ?c0 ?l0 WHERE { ?c0 rdf:type <XXXX>. OPTIONAL { ?c0 rdfs:label ?l0. } } shows two columns c0 and l0 . Any way to show only one column c0 ,but with the content of the ?l0 as the title of the ?c0 ? The result would look like select ?co as ... If I understand you correctly, you can do this with coalesce , which returns its first non-error bound argument. First, here's some data where there's a class :dog with the label "Dog" , and a class :cat which has no label: @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix : <http://example.org/> . :dog a rdfs:Class ; rdfs