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.
Related
If I have a dbpedia url (i.e., http://dbpedia.org/page/Idris_Elba), how can I query SPARQL to return all dob & foaf information and to verify if the entity (in this case Idris Elba) is a person? true/false
Current Query
PREFIX dbpedia: <http://dbpedia.org/resource/>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
select * {
values ?person { dbpedia:Idris_Elba}
?person ?p ?o
}
I'm trying to extract the date of birth of a number of people from dbpedia.org. However some queries fail because the data is in a different attribute. For example:
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbo: <http://dbpedia.org/ontology/>
select ?birthDate where {
dbr:Alan_Turing dbo:birthDate ?birthDate
}
returns 1912-06-23 as it should but:
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbo: <http://dbpedia.org/ontology/>
select ?birthDate where {
dbr:Grace_Hopper dbo:birthDate ?birthDate
}
returns an empty result.
EDIT TO ADD:
The original problem was confused by the disparity between the live.dbpedia.org and dbpedia.org, meaning despite the non-live version having dbo:birthDate in both this wasn't the same on live.dbpedia.org. If you compare Alan Turing with Grace Hopper you see they have their birthDates in two different ontologies. So the problem is now how to handle those gracefully.
The answer is to use the UNION operator to find an answer from whichever ontology has it:
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbp: <http://dbpedia.org/property/>
select ?birthDate where {
{ dbr:Alan_Turing dbo:birthDate ?birthDate }
UNION
{ dbr:Alan_Turing dbp:birthDate ?birthDate }
}
Gives us two results, both the same. And for Grace Hopper:
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbp: <http://dbpedia.org/property/>
select ?birthDate where {
{ dbr:Grace_Hopper dbo:birthDate ?birthDate }
UNION
{ dbr:Grace_Hopper dbp:birthDate ?birthDate }
}
We only get one result
As live.dbpedia.org already has a bunch of namespace prefixes defined and as suggested by #AKSW we can simplify the call even further. The distinct keyword means identical results from different taxonomies are merged together:
select distinct ?birthDate {
dbr:Grace_Hopper dbo:birthDate|dbp:birthDate ?birthDate
}
Giving this result.
I am writing SPARQL query to get all Person available in DBpedia. My query is ->
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbp: <http://dbpedia.org/property/>
SELECT ?resource ?name
WHERE {
?resource rdf:type dbo:Person;
dbp:name ?name.
FILTER (lang(?name) = 'en')
}
ORDER BY ASC(?name)
It's giving around 10000 rows,when I am taking the output as HTML/csv/spreadsheet format.
But when I am giving query to get total count
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbp: <http://dbpedia.org/property/>
SELECT COUNT(*)
WHERE{
?resource rdf:type dbo:Person;
dbp:name ?name.
FILTER (lang(?name) = 'en')
}
It's giving -> 1783404
Can anyone suggest a solution to get all rows of Person available in DBpedia?
DBPedia is being smart enough here to not overload its servers with large queries, and capping matches at 10000. Since you are ordering the results, you can use LIMIT and OFFSET to get result in sets of 10000. For example, to get the second set of 10000 results use this:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbp: <http://dbpedia.org/property/>
SELECT ?resource ?name
WHERE {
?resource rdf:type dbo:Person;
dbp:name ?name.
FILTER (lang(?name) = 'en')
}
ORDER BY ASC(?name)
LIMIT 10000 OFFSET 10000
Actually, since DBPedia is limiting the results to 10000 matches, the LIMIT isn't really necessary.
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}
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.