sparql

How to change upper execution time limit for a DBpedia SPARQL query? (Virtuoso 42000 error)

不打扰是莪最后的温柔 提交于 2020-01-02 06:30:22
问题 I am querying DBpedia using SPARQL through Python. I am facing issues with the upper execution time limit. This is the error : Code : sparql = SPARQLWrapper("http://dbpedia.org/sparql") newquery = "DEFINE input:inference "skos-trans" PREFIX dcterms: <http://purl.org/dc/terms/> select distinct ?cat1 ?cat2 ?cat3 ?cat4 where { <http://dbpedia.org/resource/Pulp_Fiction> dcterms:subject ?cat1 . ?cat1 skos:broaderTransitive ?cat2. ?cat2 skos:broaderTransitive ?cat3. ?cat3 skos:broaderTransitive

Jena: How to infer data / performance issues

喜欢而已 提交于 2020-01-02 03:40:05
问题 I'd like to use Jena's inference capabilities, but I'm having some performance problems when I am using InfModel. Here's a simplified overview of my ontology: Properties: hasX (Ranges(intersection): X, inverse properties: isXOf) |-- hasSpecialX (Ranges(intersection): X, inverse properties: isSpecialXOf) isXOf (Domains(intersection): X, inverse properties: hasX) |--isSpecialXOf (Domains(intersection): X, inverse properties: hasSpecialX) Furthermore there's a class 'Object': Object hasSpecialX

boundary for arbitrary property path in SPARQL 1.1

↘锁芯ラ 提交于 2020-01-01 18:53:10
问题 Is it possible to bound the length of property path? For example getting all the triples with lengths that are between (m,n) or all that are not between this range? For instance, how could this be done with the following query? select ?x ?y where {?x p* ?y} 回答1: Some endpoints support this directly Some SPARQL engines support a method for doing this directly, with a regular-expression-like syntax. E.g., ?s :p{n,m} ?o would be a path with a length between n and m. That syntax is described in

boundary for arbitrary property path in SPARQL 1.1

坚强是说给别人听的谎言 提交于 2020-01-01 18:52:30
问题 Is it possible to bound the length of property path? For example getting all the triples with lengths that are between (m,n) or all that are not between this range? For instance, how could this be done with the following query? select ?x ?y where {?x p* ?y} 回答1: Some endpoints support this directly Some SPARQL engines support a method for doing this directly, with a regular-expression-like syntax. E.g., ?s :p{n,m} ?o would be a path with a length between n and m. That syntax is described in

Counting in SPARQL

冷暖自知 提交于 2020-01-01 08:43:22
问题 Ok so i have this query PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT DISTINCT (COUNT(?instance) AS ?count) WHERE { ?instance a <http://dbpedia.org/ontology/Ambassador> . } and the result is 286. Cool. Now I want to get the number of ambassadors that have http://dbpedia.org/property/name property. But PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT DISTINCT (COUNT(?instance) AS ?count) WHERE { ?instance a <http://dbpedia.org/ontology/Ambassador> . ?instance <http:/

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

僤鯓⒐⒋嵵緔 提交于 2020-01-01 03:37:08
问题 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

SPARQL: Dividing a BGP into multiple Groups

房东的猫 提交于 2019-12-31 05:36:17
问题 In a previous question, a comment suggests that select ?x ?y where { {?x rdf:type ex:someType} {?x ex:someProperty ?y} } is like (not identical) to: select ?x ?y where { ?x rdf:type ex:someType. ?x ex:someProperty ?y. } Same triple patterns are used. However, the first query contains two BGPs (each one in a group pattern), while the second contains one BGP (no group patterns). The algebra for the first query is a JOIN between two BGPs while the algebra of the second is only a BGP . First

sparql query on wikidata

落花浮王杯 提交于 2019-12-31 05:23:10
问题 i am very new to sparql and i am trying to run 3 queries on wikidata: Persons who are not painters and who are students of painters. Persons who are not painters and who are academic offspring or children of painters (note: an academic offspring of a person P is somebody who is/was a student of P , or a student of a student of P , or .... ). People who are academic offspring of themselves. i got stuck on the first one, i tried: SELECT DISTINCT ?human ?humanLabel WHERE { ?human wdt:P31 wd:Q5.

SPARQL selecting MAX value of a counter

点点圈 提交于 2019-12-31 04:37:08
问题 I'm new to sparql and trying to fegure out what is the best way to select the max value of a counter of another query without creating a new table, only using sub-queries. I'm working on a relatively small dataset so the computation time is not a problem. SELECT ?p1 ?c1 (MAX(?cnt1) AS ?maxc) WHERE{ { SELECT ?p1 ?c1 (COUNT(?s1) AS ?cnt1) WHERE { ?s1 ?p1 ?o1; a ?c1. }Group by ?p1 ?c1 #ORDER BY ?p1 DESC(?cnt1) } }GROUP BY ?p1 so I'm expecting to get a row for every value of ?p1 with the max

Sparql query: find objects with same property objects

可紊 提交于 2019-12-31 03:50:06
问题 Suppose we have a dataset that looks like this: :person :wantsCD :cd1; :wantsCD :cd2 . :storeA :sellsCD :cd1; sellsCD :cd2; sellsCD :cd3 . :storeB :sellsCD :cd1; sellsCD :cd10; sellsCD :cd100 . I'm interested in finding the stores that sell all the CD's :person wants, i.e. ( :storeA ). Is it possible to get this result with a SPARQL query? The query should also work when the number of CD's the :person wants is unknown at runtime. I tried: SELECT DISTINCT ?store ?cd WHERE { :person :wantsCD