Sparql dbpedia search article by containing word - sparql

I've created sparql query for searching person and article
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?name ?person ?description
WHERE {
?person rdf:type dbo:Person.
?person foaf:name ?name .
?person rdfs:comment ?description .
FILTER (regex(?description, 'morgan freeman' ,'i')) .
FILTER (lang(?description) = 'in')
}
ORDER BY ?name
and its working when searching morgan freeman
but not working when searching article God Created All Things or Birth of Jesus
how to search acticle on dbpedia with sparql query?

Related

how can i get the result in sparql query of the following?

2.5) List the people and their names who are born in Jönköping before 1900.
2.6) Are there musical artists who were born in Jönköping? (use an ASK query).
2.7) Find 10 people (URI and place of death) who were born in Jönköping, but died elsewhere.
I am using dbpedia to run queries and fetch data
SELECT DISTINCT * WHERE {?x ?y "Jönköping"#en }
This is the URI Which is retrived
DESCRIBE http://dbpedia.org/resource/Jönköping
You can solve as following;
2.5) List the people and their names who are born in Jönköping before 1900
PREFIX db: <http://dbpedia.org/resource/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT ?name ?birth
WHERE
{
?person dbo:birthPlace db:Jönköping .
?person dbo:birthDate ?birth .
?person foaf:name ?name .
FILTER (?birth < "1900-01-01"^^xsd:date) .
}
ORDER BY ?birth
2.6) Are there musical artists who were born in Jönköping? (use an ASK query)
PREFIX db: <http://dbpedia.org/resource/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dbo: <http://dbpedia.org/ontology/>
ASK WHERE{SELECT ?person WHERE{
?person a dbo:MusicalArtist .
?person dbo:birthPlace db:Jönköping .
}}
2.7)Find 10 people (URI and place of death) who were born in Jönköping, but died elsewhere
PREFIX db: <http://dbpedia.org/resource/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT DISTINCT ?name ?person
WHERE
{
?person dbo:birthPlace db:Jönköping .
?person dbo:deathPlace ?deathPlace.
?person foaf:name ?name .
FILTER (?deathPlace != db:Jönköping) .
} ORDER BY ?name LIMIT 10

Doesnt outputs some cities

Well. Can someone explain to noob why is my code for example working with some cities like Odessa, London, Barcelona, Berlin. But does not work with Perm, Moscow, Athens and some a lot of another cities?
Changing names in quotes
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbr: <http://dbpedia.org/resource/>
SELECT *
WHERE {
?s rdfs:label "Moscow"#en .
?s dbo:populationTotal ?numberOfInhabitants .
?s dbo:country ?country .
?s dbo:leaderTitle ?cityHead
}
Wanna have query that will work with whatever city would be in the quotes.

Get birthplace from DBpedia people in SPARQL

I have the following code to retrieve all people that was born in Barcelona
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?person ?birthPlace
WHERE {
?person rdfs:label ?label.
?person rdf:type dbo:Person.
?person <http://dbpedia.org/property/birthPlace>
<http://dbpedia.org/resource/Barcelona>.
}
However, I do not know how to get the birthPlace. I want a variable that says next to each name that Barcelona is the place of birth. Any ideas?
How about this:
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?person ?birthPlace
WHERE {
?person rdfs:label ?label.
?person rdf:type dbo:Person.
?person <http://dbpedia.org/property/birthPlace> ?birthPlace.
FILTER (?birthPlace = <http://dbpedia.org/resource/Barcelona>)
}
Note that your query has a pattern to match labels, but the labels are not returned. That leads to duplicate results because some people have multiple labels (in different languages). Remove the pattern, or add ?label to the SELECT clause.
You can abbreviate <http://dbpedia.org/property/birthPlace> to dbp:birthPlace.

How to find the nobel prize winners

I'm trying to find the nobel prize winners (http://data.nobelprize.org/snorql) born in the 20 th century and their field of study from dbpedia.
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX nobel: <http://data.nobelprize.org/terms/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
SELECT (?x as ?Label) (count(?NAME) as ?Count)
WHERE {
?Name a nobel:Laureate;
dbpprop:dateOfBirth ?Date;
rdfs:label ?NAME.
FILTER ( ?Date >= "1900-01-01"^^xsd:date )
FILTER (?Date < "2000-01-01"^^xsd:date) .
?Name owl:sameAs ?n
Service <http://dbpedia.org/sparql>
{?n dbo:field ?x} }
GROUP BY ?x
ORDER BY desc(count(?Name))
The results shows me error 400 because of dbo:field. Where is the fault?

SPARQL: Federated query gives no result when using local file, while same query on dbpedia does

the local file uploaded on stardog:
#prefix dbo: <http://dbpedia.org/ontology/> .
#prefix dbr: <http://dbpedia.org/resource/> .
dbr:United_States dbo:leader dbr:John_Roberts ,
dbr:Joe_Biden ,
dbr:Barack_Obama ,
dbr:Paul_Ryan .
1.query using the local file:
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX db: <http://dbpedia.org/>
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT ?person ?o
FROM <http://example.com/leaders.ttl>
WHERE{
dbr:United_States dbo:leader ?person .
SERVICE <http://dbpedia.org/sparql> { ?person dbo:abstract ?o .}
}
2.Same query using only dbpedia will give results:
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX db: <http://dbpedia.org/>
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT ?person ?o
FROM <http://example.com/leaders.ttl>
WHERE{
#dbr:United_States dbo:leader ?person .
SERVICE <http://dbpedia.org/sparql> { dbr:United_States dbo:leader ?person. ?person dbo:abstract ?o.}
}
Using the second query will result in a colum with the leaders and a column of abstract of the leaders in all languages available from dbpedia. Why does the first query where I use the local rdf file not work? The select query on the local file with dbr:United_States dbo:leader ?person . returns exactly the same column with the same leaders as running it directly on the dbpedia endpoint: dbpedia:John_Roberts, dbpedia:Joe_Biden, dbpedia:Barack_Obama, dbpedia:Paul_Ryan.
Why does the first query give no results?