I currently have the following SPARQL query:
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX p: <http://dbpedia.org/property/>
PREFIX o: <http://dbpedia.org/ontology/>
SELECT * WHERE{
?manager p:managerclubs <http://dbpedia.org/resource/Manchester_City_F.C.>.
OPTIONAL {?manager p:cityofbirth ?city}.
OPTIONAL {?manager p:dateOfBirth ?dob}.
OPTIONAL {?manager p:image ?image}.
}
This currently returns all the managers but I want to only return the current manager, is this done via a filter or is there an alternate way of writing the query.
I also have a second question which is on the page for MCFC: http://dbpedia.org/page/Manchester_City_F.C.
How can I access the DBO data types? I assumed that simply using o: instead of p: and then calling the name of the datatype would work but this doesn't seem to be the case.
EDIT:
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX p: <http://dbpedia.org/property/>
PREFIX o: <http://dbpedia.org/ontology/>
SELECT * WHERE{
?ground p:ground <http://dbpedia.org/resource/Manchester_City_F.C.>.
OPTIONAL {?ground p:seatingCapacity ?capacity}.
OPTIONAL {?ground p:image ?image}.
}
I don't understand why the above query returns nothing in: http://dbpedia.org/sparql, from the page ground is of type dbp and there is an image and seatinCapacity for the ground.
You don't need to add filter in this case. You can just use the property o:manager:
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX p: <http://dbpedia.org/property/>
PREFIX o: <http://dbpedia.org/ontology/>
SELECT * WHERE{
<http://dbpedia.org/resource/Manchester_City_F.C.> o:manager ?manager
OPTIONAL {?manager p:cityofbirth ?city}.
OPTIONAL {?manager p:dateOfBirth ?dob}.
OPTIONAL {?manager foaf:depiction ?image}.
}
You may also use p:currentclub but I wouldn't recommended as its object is literal.
Regarding the second question, the capacity seams to be object of p:capacity but I don't see an p:image property, only foaf:depiction, which I also used on the query above for the managers.
As your first question is duly answered by Ivo, here's how your second can be improved. If you are looking for the stadium of Manchester City F.C, that fact is represented as bellow.
dbr:Manchester_City_F.C. p:ground dbr:City_of_Manchester_Stadium
You are using the relation with opposite direction. Your query should be
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX p: <http://dbpedia.org/property/>
PREFIX o: <http://dbpedia.org/ontology/>
SELECT * WHERE{
<http://dbpedia.org/resource/Manchester_City_F.C.> p:ground ?ground .
OPTIONAL {?ground p:seatingCapacity ?capacity}.
OPTIONAL {?ground p:image ?image}.
}
Related
My query is
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbp: <http://dbpedia.org/property/>
SELECT ?craft where
{
?craft <http://dbpedia.org/property/title> ?v.
}
Now this returning lot of results,
but nothing related to Steve Jobs or Tim Cook, even though in their page there is a property named title.
dbp:title dbr:List_of_Apple_Computer_CEOs
http://dbpedia.org/page/Steve_Jobs
The query:
PREFIX dbp: <http://dbpedia.org/property/>
SELECT (COUNT(*) AS ?nb_result)
WHERE {
?craft dbp:title ?v .
}
returns:
nb_result
---------
1566113
The public query endpoint for DBpedia limits the number of results to 10,000, among other restrictions. So your chances of retrieving any specific statement there are very small. If you worry that the data at the query endpoint is different than at the front end, you can check that the data is there with the query:
PREFIX dbp: <http://dbpedia.org/property/>
PREFIX dbr: <http://dbpedia.org/resource/>
SELECT ?prop ?value
WHERE {
dbr:Steve_Jobs ?prop ?value .
}
and compare with what's displayed at http://dbpedia.org/page/Steve_Jobs.
I am trying to retrieve some data about movies from DBpedia. This is my 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://dbpedia.org/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX onto: <http://dbpedia.org/ontology/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT *
{{SELECT *
WHERE {
SERVICE<http://dbpedia.org/sparql>{
?movie dcterms:subject <http://dbpedia.org/resource/Category:American_films> ;
a onto:Film ;
rdfs:label ?title ;
dbpedia2:gross ?revenue .
?movie onto:starring ?actorUri .
?actorUri rdfs:label ?actor .
OPTIONAL {
?movie onto:imdbId ?imdbId .
}
BIND(xsd:integer(?revenue) as ?intRevenue) .
FILTER ((datatype(?revenue) = 'http://dbpedia.org/datatype/usDollar') && (LANGMATCHES(LANG(?title), 'en')) && (LANGMATCHES(LANG(?actor), 'en'))) .
}
}
}}
ORDER BY DESC (?intRevenue)
LIMIT 40000
OFFSET 0
Running this query on http://dbpedia.org/snorql/ (without the SERVICE keyword) returns the correct result. However, doing so from a third party triplestore doesn't yield the same order (ex: Hobbit and Lord of the Rings are missing).
What do I need to change in the query to get identical results?
The best way to overcome this specific limitation is to have your own DBpedia mirror, on which you can set your own limits (including none), and which you can then use as either your primary or remote data store and/or query engine.
(ObDisclaimer: OpenLink Software provides the public DBpedia SPARQL endpoint, produces Virtuoso and the DBpedia Mirror AMI, and employs me.)
I am a novice in Semantic Web and I would like to retrieve all property-value pairs of "apple" from DBPedia using SPARQL query. Below I have written the query in http://dbpedia.org/sparql editor, but it returns no any results.Could you tell me where I make a mistake, please?
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix dbo: <http://dbpedia.org/ontology/>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix prov: <http://www.w3.org/ns/prov#>
prefix foaf: <http://xmlns.com/foaf/0.1/>
prefix dbp: <http://dbpedia.org/property/>
prefix dct: <http://purl.org/dc/terms/>
select * where {<http://http://dbpedia.org/page/Apple> ?property ?value}
You wrote http:// twice. Also, the correct URI for the query is /resource/, not /page/.
Working query:
select * where {<http://dbpedia.org/resource/Apple> ?property ?value}
Keep in mind this will give you information about the fruit, not the company.
I am giving you the query which will give you information about Apple Company rather than apple Fruit.
PREFIX dbprop: <http://dbpedia.org/property/>
PREFIX db: <http://dbpedia.org/resource/>
SELECT ?property, ?value WHERE {db:Apple_Inc ?property ?value}
How I can select one of rdf possible labels to send it to the Federated Search?
I have a rdf record who has several links to another databases:
<owl:sameAs rdf:resource="http://cantic.bnc.cat/registres/CUCId/a10035400"/>
<owl:sameAs rdf:resource="http://viaf.org/viaf/61502721"/>
<owl:sameAs rdf:resource="http://dbpedia.org/resource/Delfi_Abella"/>
<owl:sameAs rdf:resource="http://id.loc.gov/authorities/names/nr2005020137"/>
<owl:sameAs rdf:resource="http://d-nb.info/gnd/158288475"/>
I just get the dbpedia link to ask in dbpedia some information using It.
I create this federated search but It not works:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl/>
PREFIX rdaGr2: <http://rdvocab.info/ElementsGr2/>
PREFIX dbo:<http://dbpedia.org/ontology/>
SELECT *
WHERE {
?autid rdaGr2:dateOfBirth "1991" .
?autid owl:sameAs ?dbpediaid
FILTER regex(?dbpediaid,'dbpedia','i') .
SERVICE <http://dbpedia.org/sparql>
{
?dbpediaid dbo:birthPlace ?naixement
}
}
What I'm doing wrong?
If I use the single search:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl/>
PREFIX rdaGr2: <http://rdvocab.info/ElementsGr2/>
PREFIX dbo:<http://dbpedia.org/ontology/>
SELECT *
WHERE {
?autid rdaGr2:dateOfBirth "1991" .
?autid owl:sameAs ?dbpediaid
FILTER regex(?dbpediaid,'dbpedia','i') .
}
I get the autid and the dbpedia link.
autid dbpediaid
http://arties.cbuc.cat/openccuc/a10985256/ http://dbpedia.org/resource/Emma_Roberts
How I can tell to the SERVIE just use It.
Regards
Update (originally posted as an answer)
Maybe I'm asking badly the question:
I try to do two different sparql in just one. Using the results from the first part of question (Filter aplied) i try to ask into DBPEDIA to get the results I need.
From the first part without any Filter
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX void: <http://rdfs.org/ns/void#>
PREFIX owl: <http://www.w3.org/2002/07/owl/>
PREFIX rdaGr2: <http://rdvocab.info/ElementsGr2/>
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
PREFIX dbo:<http://dbpedia.org/ontology/>
SELECT *
WHERE {
?autid rdaGr2:dateOfBirth "1991" .
?autid owl:sameAs ?dbpediaid
}
I get this results:
http://arties.cbuc.cat/openccuc/a10603050/ http://cantic.bnc.cat/registres/CUCId/a10603050
http://arties.cbuc.cat/openccuc/a10603050/ http://viaf.org/viaf/169463957
http://arties.cbuc.cat/openccuc/a10667283/ http://cantic.bnc.cat/registres/CUCId/a10667283
http://arties.cbuc.cat/openccuc/a10667283/ http://viaf.org/viaf/303916880
http://arties.cbuc.cat/openccuc/a10895814/ http://cantic.bnc.cat/registres/CUCId/a10895814
http://arties.cbuc.cat/openccuc/a10895814/ http://viaf.org/viaf/107201286
http://arties.cbuc.cat/openccuc/a10895814/ http://d-nb.info/gnd/140511695
http://arties.cbuc.cat/openccuc/a10895814/ http://id.loc.gov/authorities/names/no2010103795
http://arties.cbuc.cat/openccuc/a10985256/ http://cantic.bnc.cat/registres/CUCId/a10985256
http://arties.cbuc.cat/openccuc/a10985256/ http://viaf.org/viaf/85925873
http://arties.cbuc.cat/openccuc/a10985256/ http://id.loc.gov/authorities/names/no2005021393
http://arties.cbuc.cat/openccuc/a10985256/ http://d-nb.info/gnd/141167203
http://arties.cbuc.cat/openccuc/a10985256/ http://dbpedia.org/resource/Emma_Roberts
http://arties.cbuc.cat/openccuc/a11019682/ http://cantic.bnc.cat/registres/CUCId/a11019682
http://arties.cbuc.cat/openccuc/a11019682/ http://viaf.org/viaf/157747131
http://arties.cbuc.cat/openccuc/a11045553/ http://cantic.bnc.cat/registres/CUCId/a11045553
http://arties.cbuc.cat/openccuc/a11045553/ http://viaf.org/viaf/126161085
I apply the filter
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX void: <http://rdfs.org/ns/void#>
PREFIX owl: <http://www.w3.org/2002/07/owl/>
PREFIX rdaGr2: <http://rdvocab.info/ElementsGr2/>
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
PREFIX dbo:<http://dbpedia.org/ontology/>
SELECT *
WHERE {
?autid rdaGr2:dateOfBirth "1991" .
?autid owl:sameAs ?dbpediaid
FILTER regex(?dbpediaid,'dbpedia','i') .
}
to jut get one result:
http://arties.cbuc.cat/openccuc/a10985256/ http://dbpedia.org/resource/Emma_Roberts
And I want to send It to the Service to the DBPEDIA but just send this URL:
http://dbpedia.org/resource/Emma_Roberts
Not all the URL I get from the first part:
http://cantic.bnc.cat/registres/CUCId/a10603050
http://viaf.org/viaf/169463957
http://cantic.bnc.cat/registres/CUCId/a10667283
http://viaf.org/viaf/303916880
http://cantic.bnc.cat/registres/CUCId/a10895814
http://viaf.org/viaf/107201286
http://d-nb.info/gnd/140511695
http://id.loc.gov/authorities/names/no2010103795
http://cantic.bnc.cat/registres/CUCId/a10985256
http://viaf.org/viaf/85925873
http://id.loc.gov/authorities/names/no2005021393
http://d-nb.info/gnd/141167203
http://dbpedia.org/resource/Emma_Roberts
Because some of them are not related to the Dbpedia and then the DBPEDIA send me an error like this:
Virtuoso RDFZZ Error DB.DBA.SPARQL_REXEC('http://dbpedia.org/sparql', ...) returned Content-Type 'text/plain' status 'HTTP/1.1 400 Bad Request
'
Virtuoso 37000 Error SP030: SPARQL compiler, line 3: syntax error at '_' before ':'
SPARQL query:
define sql:big-data-const 0 SELECT ?naixement
WHERE { <http://dbpedia.org/resource/Emma_Roberts> <http://dbpedia.org/ontology/birthPlace> ?naixement .
FILTER (_::default-20-7 = <http://arties.cbuc.es:8990/CCUCAF>) }
SPARQL query:
define sql:big-data-const 0
#output-format:text/html
define sql:signal-void-variables 1 define get:soft "soft" define input:default-graph-uri <http://arties.cbuc.es:8990/CCUCAF> PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX void: <http://rdfs.org/ns/void#>
PREFIX owl: <http://www.w3.org/2002/07/owl/>
PREFIX rdaGr2: <http://rdvocab.info/ElementsGr2/>
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
PREFIX dbo:<http://dbpedia.org/ontology/>
SELECT ?naixement
WHERE {
?autid rdaGr2:dateOfBirth "1991" .
?autid owl:sameAs ?dbpediaid
filter regex( str(?dbpediaid),'dbpedia','i')
SERVICE <http://dbpedia.org/sparql>
{
?dbpediaid dbo:birthPlace ?naixement
}
FILTER regex(?dbpediaid,'dbpedia','i') should probably fail, since ?dbpediaid isn't a string; but a URI. Instead, you should be doing FILTER regex(str(?dbpediaid),'dbpedia','i'). The fact that your second query returns some results, though, makes it seem like the URI is implicitly being converted to a string. That might be an extension of the particular implementation you're using, though.
However, when I use Apache Jena to execute the following query, I get empty results:
prefix dbpedia: <http://dbpedia.org/resource/>
prefix dbpedia-owl: <http://dbpedia.org/ontology/>
select * where {
bind( dbpedia:Emma_Roberts as ?dbpediaid )
filter regex( ?dbpediaid,'dbpedia','i')
service <http://dbpedia.org/sparql> {
?dbpediaid dbpedia-owl:birthPlace ?naixement
}
}
-------------------------
| dbpediaid | naixement |
=========================
-------------------------
If I make the change to using str(?dbpediaid), I get results:
prefix dbpedia: <http://dbpedia.org/resource/>
prefix dbpedia-owl: <http://dbpedia.org/ontology/>
select * where {
bind( dbpedia:Emma_Roberts as ?dbpediaid )
filter regex( str(?dbpediaid),'dbpedia','i')
service <http://dbpedia.org/sparql> {
?dbpediaid dbpedia-owl:birthPlace ?naixement
}
}
--------------------------------------------------------------------------------------
| dbpediaid | naixement |
======================================================================================
| dbpedia:Emma_Roberts | <http://dbpedia.org/resource/Rhinebeck_(village),_New_York> |
--------------------------------------------------------------------------------------
Note that this could be a very expensive query if the query engine does the service part first, as it would retrieve all the dbpedia-owl:birthPlace triples first, bring them back, and then match against the particular one that you care about. There may be different behavior if rather than using bind, like I did above, the value of ?dbpediaid is simply coming from some triple matches.
I want to get all pages which have a specified category and a specified key. My query:
PREFIX dbpedia: <http://dbpedia.org/>
PREFIX dbpedia2: <http://dbpedia.org/property/>
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
PREFIX dcterms: <http://dublincore.org/2010/10/11/dcterms.rdf#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX grs: <http://www.georss.org/georss/point>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?page ?cat ?key ?value (lang(?value) as ?language) WHERE {
?page dcterms:subject ?cat .
?page ?key ?value .
FILTER(
regex(?cat, "category:Amusement_parks_in_the_Netherlands") &&
?key = foaf:depiction
)
}
But it return zero results. See here: SNORQL query
It should at least return this page: http://dbpedia.org/page/Duinrell (because it matches the criteria).
Any ideas?
There's a couple of things wrong with your query. First of all, don't use a regex when comparing URIs. Instead of:
regex(?cat, "category:Amusement_parks_in_the_Netherlands")
use:
?cat = <http://dbpedia.org/resource/category:Amusement_parks_in_the_Netherlands>
Second: your namespace prefix for dublin core seems wrong. You are querying the property dcterms:subject, and in your query, the prefix dcterms is mapped to the namespace http://dublincore.org/2010/10/11/dcterms.rdf#. However, the actual property in DBPedia is http://purl.org/dc/terms/subject, so your namespace prefix should map to http://purl.org/dc/terms/ instead.