I have problem with SPARQL. I want to select something from category. For example subjects. I make query like this in http://dbpedia.org/snorql.
SELECT ?category ?subject WHERE
{
?category a skos:Concept .
?category skos:Concept: American_punk_rock_guitarists.
?category dct:subject ?subject .
} LIMIT 1000
I have error Virtuoso 37000. I don't understand why.
P.S. Is it good book for beginnier in SPARQL - Learning SPARQL, 2nd Edition
Querying and Updating with SPARQL 1.1 ?
You have at least one syntax error: the second colon (:) in the second triple.
Semantically... I don't really know the classes or predicates in dbpedia... but can skos:Concept be both a type and a predicate?
I wrote you a valid query that returns 10 members of the category "American_punk_rock_guitarists"
I put this together by going to dbpedia's faceted free text search and familiarizing myself with the concept of American punk rock guitarists, specifically Joey Ramone
prefix dbpcat: <http://dbpedia.org/resource/Category:>
SELECT ?subject ?category
WHERE
{ values ?category { dbpcat:American_punk_rock_guitarists } .
?subject dct:subject ?category }
LIMIT 10
In terms of the Virtuoso 37000 error, your mistakes were the following:
You had : after skos:Concept in line 2. and you were missing a prefix for "American_punk_rock_guitarists".
American_punk_rock_guitarists should have been dbpcat:American_punk_rock_guitarists. Though this is going to give you an empty result, the syntactically correct version or your query is:
prefix dbpcat: <http://dbpedia.org/resource/Category:>
SELECT ?category ?subject WHERE
{
?category a skos:Concept .
?category skos:Concept dbp:catAmerican_punk_rock_guitarists.
?category dct:subject ?subject .
} LIMIT 1000
This returns an empty set because of the following:
a. skos:Concept is a class, not a property. In terms of {?Subject ?Predicate ?Object}, you will only see skos:Concept as a ?Subject and/or ?Object in a proper SPARQL query [1]. An easy way to differentiate classes and properties is that classes are supposed to start with a capital letter (ex: skos:Concept), and properties (predicates) should start with a lowercase letter (ex: rdf:type).
b. dbpcat:American_punk_rock_guitarists is of type "skos:Concept". If you look at the DBPedia page for this entity (?subject), you will see this in the "rdf:type" row. Look further and you'll see that this concept is a dct:subject of various other entities [2].
In addition to @Mark Miller's query this one will also provide results:
prefix dbpcat: <http://dbpedia.org/resource/Category:>
SELECT ?subject ?category
WHERE
{ ?subject dct:subject ?category.
?category a skos:Concept.
filter(?category = dbpcat:American_punk_rock_guitarists).
}
LIMIT 10
skos:Concept isn't needed here, solely as an example of how it would be used if you were looking for something such as "all ?category of type - skos:Concept".
Links:
- https://www.w3.org/2009/08/skos-reference/skos.html#Concept
- http://dbpedia.org/resource/Category:American_punk_rock_guitarists