sparql

sparql using wikiPageRedirects

半腔热情 提交于 2019-12-10 16:37:56
问题 I am using sparql to find a location of entity. I have urls from dbpedia-spootlight and want to find location for them. So the query I am using is: PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> PREFIX dbo: <http://dbpedia.org/ontology/> SELECT DISTINCT * WHERE { ?uri rdfs:label ?label . OPTIONAL { ?uri geo:lat ?lat . ?uri geo:long ?long } . OPTIONAL { ?uri dbpedia-owl:country ?dbpediaContry . ?dbpediaContry dbpprop:cctld ?ccTLD } . FILTER (?uri = <URL> && lang(?label) = "en" ) } and

Wikipedia API and SPARQL in a single query

梦想与她 提交于 2019-12-10 16:08:36
问题 I need to search for Wikipedia pages that contain some specific words in their full text . To improve the results I want to limit the results to pages describing entities that are instances of a specific entity. For searching the full text I can use the Wikipedia APIs, using the query action and the search generator . For filtering instances of a given entity I can use the Wikidata APIs and a SPARQL query. Is there a way to execute both operations in a single query that applies both filters?

Ask if SPARQL resource exists

こ雲淡風輕ζ 提交于 2019-12-10 15:44:14
问题 What is a good way to check if a SPARQL resource exists? I'm searching for the equivalent of firing a HTTP GET request to e.g. http://dbpedia.org/resource/Game_of_Thrones and check the HTTP status code but I'd like to do it with a SPARQL query. I thought about something like this: ASK {<http://dbpedia.org/resource/Game_of_Thrones> a <http://dbpedia.org/resource/>} I'm sure there is a good way to do this but I can't find it. Note: I don't want to check for the existance of a specific triple. I

Find which direct property applied in a SPARQL query

﹥>﹥吖頭↗ 提交于 2019-12-10 14:56:15
问题 I have a list of properties I want to apply to a specific entity mathematics: wd:Q395 . In this case: instanceOf: 'wdt:P31' subclassOf: 'wdt:P279' The results are: Mathematics is instance of academic discipline and Mathematics is subclass of exact science and formal science Instead of making two different queries I would like to make them all at once: SELECT ?field ?fieldLabel ?propertyApplied WHERE { wd:Q395 wdt:P31 | wdt:P279 ?field. SERVICE wikibase:label { bd:serviceParam wikibase

Power (exponentiation) and other math function support in SPARQL

送分小仙女□ 提交于 2019-12-10 14:38:58
问题 I am trying to write a SPARQL query where I want to filter on the square of something, but I am simply unable to figure out how to square a number ( x 2 ) (except by multiplying it with itself, of course). I guessed a square root function called math:sqrt() which works, yet nothing like math:pow seems to exist. How do I get the square of something in SPARQL and, more importantly, where can I read about it and other math functions such as math:sqrt in SPARQL? Note: This is related to my

How to reference a page that contains parenthesis in SPARQL

谁说胖子不能爱 提交于 2019-12-10 14:15:23
问题 I am trying to lookup information regarding someone on Dbpedia but their name contains parenthesis in this case ending with _(musician) which leads to an error. SELECT ?birthPlace WHERE { dbpedia:Tom_Johnston_(musician) dbpprop:birthPlace ?birthPlace } 回答1: Parentheses aren't legal in prefixed names, but you can just use the full URI instead: SELECT ?birthPlace WHERE { <http://dbpedia.org/resource/Tom_Johnston_(musician)> dbpprop:birthPlace ?birthPlace } It's also possible to escape them

how to remove duplicates in sparql query

▼魔方 西西 提交于 2019-12-10 13:32:48
问题 I wrote this query and return list of couples and particular condition. ( in http://live.dbpedia.org/sparql) SELECT DISTINCT ?actor ?person2 ?cnt WHERE { { select DISTINCT ?actor ?person2 (count (?film) as ?cnt) where { ?film dbo:starring ?actor . ?actor dbo:spouse ?person2. ?film dbo:starring ?person2. } order by ?actor } FILTER (?cnt >9) } Problem is that some rows is duplicate. example: http://dbpedia.org/resource/George_Burns http://dbpedia.org/resource/Gracie_Allen 12 http://dbpedia.org

sparql join query explanation hows its working?

帅比萌擦擦* 提交于 2019-12-10 12:35:11
问题 My query: select ?x ?z where { ?x <http://purl.uniprot.org/core/name> ?y . ?x <http://purl.uniprot.org/core/volume> ?z . ?x <http://purl.uniprot.org/core/pages> "176-186" . } I required to make custom parser for this query. When I do this query on jena model, it returns one record. Can anyone explain this query implementation? I split out this query into three parts: select ?x ?y where { ?x <http://purl.uniprot.org/core/name> ?y . } Total Records Found : 3034 select ?x ?z where { ?x <http:/

Sparql: how to GROUP BY More Than One Column

馋奶兔 提交于 2019-12-10 12:32:54
问题 In SPARQL, we can group the rows by a column through the gollowing syntax: GROUP BY ?colName Can we group by more than 1 columns eg: GROUP BY (?colName1 + ?colName2 + ?colName3) Suppose a query like: Select ?a ?b ?c (MIN(?y) AS ?d) Where { .... } GROUP BY (?a + ?b + ?c) But this query does not work. 回答1: You can GROUP BY multiple variables (not columns) by listing them with a space in between: GROUP BY ?a ?b ?c 回答2: In addition to Ben Companjen's answer of GROUP BY ?a ?b ?c you need to fix

parameterized SPARQL Query

浪尽此生 提交于 2019-12-10 12:26:52
问题 I want to code a parameterized SPARQL Query in Java Jena where one of the triple in query be injected so in the code below I need to inject value as a string the pass to the class However, the SPARQL query is correct so when I replace "value" with the class name I got the right result I tried two code non of them worked No result or run time error the first code: package ontology; import org.apache.jena.iri.impl.Main; import com.hp.hpl.jena.query.ParameterizedSparqlString; import com.hp.hpl